(Use DevC++) 2. Student Grade Write a program that reads a student name followed by five test scores. The program should output the student name, the five test scores, and the average test score. Output the average test score with two decimal places. The data to be read is stored in a file called test.txt. The output should be stored in a file called testavg.out. Input: A file containing the student name and the five test scores. A sample input is: Andrew Miller 87.50 89 65.75 37 98.50 Output: The student name, the five test scores, and the average of the five test scores, saved to a file. The program needs to read a student’s first and last name and five test scores. Therefore, you need two variables to store the student name and five variables to store the five test scores. To find the average, you must add the five test scores and then divide the sum by 5. Thus, you need a variable to store the average test score. Furthermore, because the input data is in a file, you need an ifstream variable to open the input file. Because the program output will be stored in a file, you need an of stream variable to open the output file. The program, therefore, needs at least the following variables: ifstream inFile; //input file stream variable ofstream outFile; //output file stream variable double test1, test2, test3, test4, test5; //variables to //read the five test scores double average; //variable to store the average test score string firstName; //variable to store the first name string lastName; //variable to store the last name
(Use DevC++)
2. Student Grade
Write a
two decimal places.
The data to be read is stored in a file called test.txt. The output should be stored in a file called
testavg.out.
Input: A file containing the student name and the five test scores. A sample input is:
Andrew Miller 87.50 89 65.75 37 98.50
Output: The student name, the five test scores, and the average of the five test scores, saved to a file.
The program needs to read a student’s first and last name and five test scores. Therefore, you need two variables to store the student name and five variables to store the five test scores. To find the
average, you must add the five test scores and then divide the sum by 5. Thus, you need a variable to store the average test score. Furthermore, because the input data is in a file, you need an ifstream
variable to open the input file. Because the program output will be stored in a file, you need an of stream variable to open the output file. The program, therefore, needs at least the following
variables:
ifstream inFile; //input file stream variable
ofstream outFile; //output file stream variable
double test1, test2, test3, test4, test5; //variables to
//read the five test scores
double average; //variable to store the average test score
string firstName; //variable to store the first name
string lastName; //variable to store the last name
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)