Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need both done soon. Templates are already made and are too be used. Program 1: Flag-controlled while Loops In a flag-controlled while loop a boolean

Need both done soon. Templates are already made and are too be used.
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Program 1: Flag-controlled while Loops In a flag-controlled while loop a boolean variable is used as the loop condition. That means you need to declare a boolean variable for each while loop and use that variable as the condition, For your program you will ask for user input and loop until the user enters valid input. This sort of input validating is necessary for any real user input. First ask the user a yeso question of your choice and ask them to input yorn as their answer. Check to make sure the input is valid (y or n). Then ask the user to enter her age and make sure that input is valid. If the user does not enter a number, then the input stream goes into the fail state and the variable is unchanged. You need to reset the input stream, clear whatever is on the input stream, then ask the user to try again. This is how you check the input stream and reset it back into working order: if lain) Linde). innoce 2000, ' '); > Here is some code to get you started: flag while input.cpp. Download this starter program, create a project in Visual C++ using this starter program, and complete the program. Your output should look similar to the CAUsers\creilly\Documents\Visual Studio 2008\Projects\CSC11370_Fall2011\UserinputCheck Debu x Do you like ice crean? > Incorrect value Do you like ice crean? ( yn): 8 Incorrect value Do you like ice crean? ( yn): y Enter your age as an integer: abcdefg You must enter an integer Enter your age as an integer: 34 Thanks for your input Press any key to continue.. Wollowing figure. 1 #include (ainclude #include using namespace std; Rint main() int grade; // The grade entered by the user int sym; // Sum of the grades int count; // Number of grades entered double avg: 11 Average of the grades -4 -5 26 27 L8 29 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 // Start of your code 11 Loop until the user enters -1 // Each time through the loop, add the number input by the user // to the sum. Make sure not to include the sentinal value in the 11 sum or count! // Find the average of the grades entered by the user 11 and print the result 41 B 1/ End of your code 42 43 44 45 46 47 48 49 50 51 52 system("pause"); return

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

how would you have done things differently?

Answered: 1 week ago

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago