Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered

In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each students average grade and the average quiz grade for the class.

Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each students quiz grades to a file. Then read the data from the file in order to display the students average score and the class average.

Use the data below when executing your program. Enter 7 items for each student. Column 1 is the student ID and Column 2-7 are the quiz grades.

Student id

Quiz 1

Quiz 2

Quiz 3

Quiz 4

Quiz 5

Quiz 6

1000

90

100

81

100

70

81

1001

85

95

86

100

87

96

1002

50

60

74

100

75

89

1008

100

93

87

100

91

88

Requirements:

Use a nested loop structure to input the data and write the data to a text file (have the user enter the text file name):

The outer loop will be a while loop; the inner loop will be a for loop (6 quizzes).

Validate whether the quiz scores are in range 0 100, inclusive.

Since you do not know how many students will be entered, determine a way to quit the loop.

Add spaces in between each item added to the text file, except add a new line after each complete set of student data.

The text file that your program creates should look like the format in the example below, but the actual data may be different:

Use a nested loop structure to read the data from the text file and calculate the students average grade (validate that the file is available):

The outer loop will be a while loop; the inner loop will be a for loop

To calculate each students average score, use a total variable initialized to 0 before the for loop, then calculate the students average after the loop.

To calculate the class average, initialize a classTotal variable to 0 before the while loop, add each students total into the classTotal following the for loop, then calculate the classAverage after the while loop.

Only display 1 decimal position for the averages.

BEWARE of integer division.

Use cout to display the values of the variables. Your cout statements MUST use the variables to display the values

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

Database Systems For Advanced Applications Dasfaa 2023 International Workshops Bdms 2023 Bdqm 2023 Gdma 2023 Bundlers 2023 Tianjin China April 17 20 2023 Proceedings Lncs 13922

Authors: Amr El Abbadi ,Gillian Dobbie ,Zhiyong Feng ,Lu Chen ,Xiaohui Tao ,Yingxia Shao ,Hongzhi Yin

1st Edition

3031354141, 978-3031354144

More Books

Students also viewed these Databases questions

Question

Solve each equation. 2x + 3 5 x-4 2

Answered: 1 week ago