Question: Task 4.1: Write a program that prompts the user to enter the number of students in the class and loops to read in that many

Task 4.1: Write a program that prompts the user to enter the number of students in the class and loops to read in that many test scores. Once all the scores have been read in, the program computes and displays the average of the test scores entered. Input Validation: Dont accept a number less than 1 or greater than 25 for the number of students. Test scores should be in the arrange of 0 ~ 100. Input the number of students in the class test scores Output the average of test scores An example of test run csci2>a.out How many students are in the class? 30 The number of students must be in the range 1 - 25.

How many students are in the class? 0 The number of students must be in the range 1 - 25.

How many students are in the class? 5

Enter the score for student 1: 120 The test score must be between 0 and 100. Enter the score for student 1: -52 The test score must be between 0 and 100.

Enter the score for student 1: 89 Enter the score for student 2: 740 The test score must be between 0 and 100. Enter the score for student 2: 74 Enter the score for student 3: 54 Enter the score for student 4: 98 Enter the score for student 5: 65 The average is 76.

Task 4.2: Modify the program in Task 4.1 so that all output are displayed into a file. Once all the scores have been read in and the average has been calculated, the program displays a message to indicate the end of output. Input the number of students in the class test scores Output a simple message

Hint About how to output data to a file Please refer to the program Pr5-17.cpp posted on d2l about how to write data to a file.

An Example of Test Run csci2>a.out How many students are in the class? 50 The number of students must be in the range 1 - 25.

How many students are in the class? 5

Enter the score for student 1: 120 The test score must be between 0 and 100. Enter the score for student 1: -52 The test score must be between 0 and 100.

Enter the score for student 1: 89 Enter the score for student 2: 54 Enter the score for student 3: 740 The test score must be between 0 and 100.

Enter the score for student 3: 74 Enter the score for student 4: 65 Enter the score for student 4: 85 A list of student scores and the average have been saved into the file "studentScores.dat". Please open the file to check it. Grading your lab

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!