Question: Help pls!! Mast1-10 CSP Lab 4: Decision and Repetition Problem: Your task: implement in C++ the algorithm solution shown below. Then analyze it and explain,

Mast1-10 CSP Lab 4: Decision and Repetition Problem: Your task: implement in C++ the algorithm solution shown below. Then analyze it and explain, using just one or two sentences, what it does. Write this explanation as a comment at the top of your program. This explanation will be worth 5 points of your total grade. Do not be too detailed (for example, do not write: it opens a file and then declares variables, and then reads from a file...); it should look like the problem 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 if the value entered is outside the range (1...100). If the value is outside the range, display an error message and stop the program. 9. Set counter to 0. 10. While (counter is less than total) 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 sum/counter 15. Closes the file. HSTO Tue Mar Boom Window HOD learn-us-east-1-prod-fleet02-xythos.content.blackboardcide.com httsteam-us-ost-prod-reto Home- 14. Print the "The average is ", followed by sum/counter. 15. Closes the file. 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 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 average since there might be no passing grades among those values processed now. Make sure your program does not divide by zero and prints a message in these cases (run my sample solution to see how this works)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
