Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please complete both thank you!! Program 1: Flag-controlled while Loops In a flag-controlled while loop a booleao variable is used as the loop condition. That

Please complete both thank you!! image text in transcribed
image text in transcribed
Program 1: Flag-controlled while Loops In a flag-controlled while loop a booleao variable is used as the loop condition. That means you need to declare a balean 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 y or n 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: ition) sin.dear ce 2000, Here is some code to get you started flog while input.Co 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 c:\Users\creilly Documents\Visual Studio 2008\Projects|CSC11370_ Fall2011\UserInputCheck Debu... Do you like ice crean? ( yn)! X Incorrect value Do you like ice crean? Cyn): 8 incorrect value Do you like ice creant cyn>: 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.. Following figure Program 2: Sentinal-controlled while Loops A seatinal controlled while loop keeps looping until the user enters a specific value. We call this value the sentinal value. Your program will ask the user to input a series of grades, and to input-1 (a sential value) when finished. You will take the average of the grades, being careful to not include the seatisal value (-1) in the average Here is some code to get you started avrGradesSentinal.com Download this starter program, create a project for it in Visual C++, and complete the program Your output should look like the following figure. Turn in your completed program. x c\Users creilly Documents\Visual Studio 2008\Projects CSC11370 Fall2011\AvgGradesSentinal De... Enter a grade, or -1 to stop: 85 Enter a grade or -1 to stop: 93 Enter a grade. or -1 to stop: 99 Enter a grade. or -1 to stop: 72 Enter a grade. or -1 to stop: 89 Enter a grade. or -1 to stop: -1 The average is: 87.6 Press any key to continue

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

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions