(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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

(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

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY