can you help me with this

Write a program that reads from a file (with variable number of records) student names and the grades for 2 tests and 3
assignments (the points are between 0 and 100) and determines and outputs for each student the average score for the
2 tests (column Tests Avg)1, average score for the 3 assignments (column Assignments Avg)2, the overall total
points for all tests and assignments (column Points), the numeric grade (column Numeric Grade)3 (between 0 and
100) and the letter grade (column Letter Grade)4. The program should also compute and output the number of
students (row Number), the minimum numeric grade (row Minimum), maximum numeric grade (row Maximum) and
average numeric grade (row Average) among all students and displays them with 2 decimals. Display the output in the
format shown below (use 2 decimals for floating-point numbers and the columns and alignment suggested bellow):

Sample input file: Sample output:
Jerry A 90 70 90 95 80
Mary B 75 90 85 100 90
Abdul C 55 80 80 80 80
Maya D 95 80 100 80 80
Carol E 80 100 90 80 100
Hung F 55 90 75 100 90
Lana G 85 90 100 90 90
Gerald H 35 60 55 60 80
Tyrone I 60 60 50 60 80
Rajiv J 85 75 95 80 80
Gabriela K 90 85 100 90 90
Randy L 95 80 100 85 90
Andrea M 75 80 80 85 80
Irina N 100 95 100 100 90
Juan O 85 90 90 90 80
STUDENT STATISTICS:
Name
Tests
Avg
Assignments
Avg
Points
Numeric
Grade
Letter
Grade
Jerry A 80.00 88.33 425.00 85.00 B
Mary B 82.50 91.67 440.00 88.00 B
Abdul C 67.50 80.00 375.00 75.00 C
Maya D 87.50 86.67 435.00 87.00 B
Carol E 90.00 90.00 450.00 90.00 A
Hung F 72.50 88.33 410.00 82.00 B
Lana G 87.50 93.33 455.00 91.00 A
Gerald H 47.50 65.00 290.00 58.00 F
Tyrone I 60.00 63.33 310.00 62.00 D
Rajiv J 80.00 85.00 415.00 83.00 B
Gabriela K 87.50 93.33 455.00 91.00 A
Randy L 87.50 91.67 450.00 90.00 A
Andrea M 77.50 81.67 400.00 80.00 B
Irina N 97.50 96.67 485.00 97.00 A
Juan O 87.50 86.67 435.00 87.00 B
CLASS STATISTICS:
Number: 15
Minimum: 58.00
Maximum: 97.00
Average: 83.07
Your program should work for any of the files from the assignment (File1.txt, File2.txt, and File3.txt) and any
other files that have the correct format.
// assignment3.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include"iostream"
#include"fstream"
#include"string"
#include"iomanip"

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
//Declare variables to manipulate data

string firstname;
string lastname;
string test1;
string test2;
string assignment1;
string assignment2;
string assignment3;
char grade = ' ';
double sum = 0;
int count = 0;
int scores[5];
//Declare stream variables
ifstream infile;
ofstream outfile;
//open input file
infile.open("cha5_stdata.txt");
if (!infile)
{
cout << "cannot open input file."
<< "program terminates!" << endl;
return 1;
}
//open output file
outfile << fixed << showpoint << setprecision(2);
infile >> firstname >> lastname; //read the name
infile >> testscore; //read the testscore

while (infile)
{
sum = sum + testscore;//update sum
count++; //increment count

//determine the grade
switch (static_cast<int> (testscore) / 10)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
grade = 'F';
break;
case 6:
grade = 'D';
break;
case 7:
grade = 'C';
break;
case 8:
grade = 'B';
break;
case 9:
case 10:
grade = 'A';
break;

default:
cout << "invalid score." << endl;
} //end switch

outfile << left << setw(12) << firstname
<< setw(12) << lastname
<< right << setw(4) << testscore
<< setw(2) << grade << endl;
infile >> firstname >> lastname; //read the name
infile >> testscore; //read the testscore
}//end while
outfile << endl;
if (count != 0)
outfile << "class average:" << sum / count
<< endl;
else
outfile << "No data." << endl;
infile.close();
outfile.close();

return 0;
}

my code haven't done yet, can you help me
Topic archived. No new replies allowed.