Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to do this lab assignment Your task: implement in C++ the algorithm solution shown below. Then analyze it and explain, using one or two

How to do this lab assignment
image text in transcribed
Your task: implement in C++ the algorithm solution shown below. Then analyze it and explain, using one or two sentences, what it does. Write this explanation as a comment at the top of your program explanation will be worth 5 points of your total grade. Do not be too detailed (for example, do not w it opens a file and then declares variables, and then reads from a file...); it should look like the prob descriptions in my previous lab assignments. Part A (79 points) Algorithm solution (in pseudocode): 1. Declare variable in File to get the data from an input file 2. Declare variables grade, counter, and total that hold a whole numbers. 3. Declare and initialize to zero a variable named sum that hold a whole numbers 4. Open file input9.txt 5. Check if the file was opened (if not opened, show an error message and stop the program). 6. Prompt the user to enter the number of grades to process. 7. Get the value from the keyboard and store it in total. 8. Check i message and stop the program. 9 Set counter to 0. 10. While (counter is less than total) f the value entered is outside the range (1... 100). If the value is outside the range, display an error 11. Get the value from the file and store it in grade. 12. Accumulate its value in sum. 13. Increment the counter. 14. Print the The average is", followed by the value returned by the function average (sum,total). 15. Closes the file. Function average() receives the values of sum and total, calculates the average, and rounds it to the nearest whole number (ones) before returning it. Use appropriate type casting to avoid loss of information when calculating the average. Part B (10 points) Modify steps 9 through 13 so that the loop is implemented with a for-loop Part C(11 points) Modify steps 6 through 8 in the above program so that, instead of stopping the program, it keeps asking the user to enter a valid value until it is entered. Note; use a do-loop. See my sample solution to see what your program must do. To clear the sereen before prompting the user to enter the value use system("cls"):. To pause your program so the user can read your message use system pause") Modify step 12. so that only the passing grades (70 through 100) are considered to calculate the average. Be careful here when you calculate the averape since there might be no passing grades among those MacBook Air

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

More Books

Students also viewed these Databases questions