New to c++, needing assistance

All, Please help. I am new to c++ at college. I have no programming experience.
This is a program I am working and not having any luck. I am to display grades for seven fictitious people.
I am to do the following.
"To create and execute a C++ program that will read student information from an input text file, calculate the test average, program average, course average, and the letter grade earned and output the result to the monitor as well as to an output text file. The letter grade earned is based on the sum of the total points earned as noted below".

1. I need to get the program to average the scores of the characters. The characters and their grades are listed below.
Snow White 77 87 76 82 92 96 90
Jack Frost 67 77 87 88 86 89 96
Sleeping Beauty 90 89 78 88 86 85 93
Prince Charming 92 87 88 89 90 91 78
Rapunzel Repunzel 66 76 73 81 85 70 86
Santa Claus 90 89 95 86 88 94 99
Miss Horner 65 76 72 50 69 75 92
2. I do not know where to put my else if loop.
3. I don't know how I need to use my fstream to recall the characters and their grades to compile the program.

Thanks

//Control Structures and File Input/Output
//Programmer:
#include <iostream>
#include <iomanip>
#include <conio.h>
#include <fstream>
#include <string>
using namespace std;

int main()
{
ifstream fin;
ofstream fout;
int prog1, prog2, prog3, prog4, prog5, test1, test2, totalPoints;
string firstName, lastName;
float progAvg, testAvg, totalAvg;
fin.open("Input.txt");
fout.open("Output.txt");

//if(grade >= 90)
//cout<<"The grade is an A."<<endl;
//else if (grade >=80)
//cout<<"The grade is a B."<<endl;
//else if (grade >=70)
//cout<<"The grade is a C."<<endl;
//else
//cout<<"The grade is an F."<<endl;



cout<<fixed<<setprecision(2)<<showpoint;
cout<<"012345678901234567890123456789012345678901234567890123456789"<<endl;
cout<<setw(60)<<setfill('*')<<"*"<<endl;
cout<<"*"<<setw(59)<<setfill(' ')<<"*"<<endl;
cout<<setfill(' ')<<left<<setw(10)<<"*"<<"IT210 Business Applications with C++"<<setw(14)<<right<<"*"<<endl;
cout<<left<<setw(10)<<"*"<<"Programmer: "<<setw(27)<<right<<"*"<<endl;
cout<<left<<setw(10)<<"*"<<"Date: October 26, 2010"<<setw(27)<<right<<"*"<<endl;
cout<<"*"<<setw(59)<<setfill(' ')<<"*"<<endl;
cout<<left<<setw(10)<<"*"<<"Program Assignment 2: Student Grades II"<<setw(11)<<right<<"*"<<endl;
cout<<"*"<<setw(59)<<setfill(' ')<<"*"<<endl;
cout<<left<<setw(10)<<"*"<<"This program reads student information from"<<setw(7)<<right<<"*"<<endl;
cout<<left<<setw(10)<<"*"<<"an input text file and outputs the results"<<setw(8)<<right<<"*"<<endl;
cout<<left<<setw(10)<<"*"<<"to the monitor as well as to a text file"<<setw(10)<<right<<"*"<<endl;
cout<<"*"<<setw(59)<<setfill(' ')<<"*"<<endl;
cout<<setw(60)<<setfill('*')<<"*"<<endl;
cout<<"\n1234567890123456789012345678901234567890123456789012345678901234567890"<<endl;
cout<<setw(70)<<setfill('=')<<"="<<endl;
cout<<setfill(' ')<<setw(20)<<left<<"Student Name"<<setw(10)<<"Total"<<setw(10)<<"Program"<<setw(10)<<"Test"<<setw(10)<<"Course"<<setw(10)<<"Grade"<<endl;
cout<<setw(20)<<"Points"<<setw(10)<<"Average"<<setw(10)<<"Average"<<setw(10)<<"Average"<<endl;
cout<<setw(70)<<setfill('-')<<"-"<<setfill(' ')<<endl;


fout<<fixed<<setprecision(2)<<showpoint;
fout<<"012345678901234567890123456789012345678901234567890123456789"<<endl;
fout<<setw(60)<<setfill('*')<<"*"<<endl;
fout<<"*"<<setw(59)<<setfill(' ')<<"*"<<endl;
fout<<setfill(' ')<<left<<setw(10)<<"*"<<"IT210 Business Applications with C++"<<setw(14)<<right<<"*"<<endl;
fout<<left<<setw(10)<<"*"<<"Programmer: "<<setw(30)<<right<<"*"<<endl;
fout<<left<<setw(10)<<"*"<<"Date: October 26, 2010"<<setw(26)<<right<<"*"<<endl;
fout<<"*"<<setw(59)<<setfill(' ')<<"*"<<endl;
fout<<left<<setw(10)<<"*"<<"Program Assignment 2: Student Grades II"<<setw(11)<<right<<"*"<<endl;
fout<<"*"<<setw(59)<<setfill(' ')<<"*"<<endl;
fout<<left<<setw(10)<<"*"<<"This program reads student information from"<<setw(7)<<right<<"*"<<endl;
fout<<left<<setw(10)<<"*"<<"an input text file and outputs the results"<<setw(8)<<right<<"*"<<endl;
fout<<left<<setw(10)<<"*"<<"to the monitor as well as to a text file"<<setw(10)<<right<<"*"<<endl;
fout<<"*"<<setw(59)<<setfill(' ')<<"*"<<endl;
fout<<setw(60)<<setfill('*')<<"*"<<endl;
fout<<"\n1234567890123456789012345678901234567890123456789012345678901234567890"<<endl;
fout<<setw(70)<<setfill('=')<<"="<<endl;
fout<<setfill(' ')<<setw(20)<<"Student Name"<<setw(10)<<"Total"<<setw(10)<<"Program"<<setw(10)<<"Test"<<setw(10)<<"Course"<<setw(10)<<"Grade"<<endl;
fout<<setw(20)<<"Points"<<setw(13)<<"Average"<<setw(13)<<"Average"<<setw(13)<<"Average"<<endl;
fout<<setw(70)<<setfill('-')<<"-"<<setfill(' ')<<endl;



cout<<"Snow White 77 87 76 82 92 96 90 "<<endl;
cout<<"Jack Frost 67 77 87 88 86 89 96 "<<endl;
cout<<"Sleeping Beauty 90 89 78 88 86 85 93 "<<endl;
cout<<"Prince Charming 92 87 88 89 90 91 78 "<<endl;
cout<<"Rapunzel Repunzel 66 76 73 81 85 70 86 "<<endl;
cout<<"Santa Claus 90 89 95 86 88 94 99 "<<endl;
cout<<"Miss Horner 65 76 72 50 69 75 92 "<<endl;

fout<<"Snow White 77 87 76 82 92 96 90 "<<endl;
fout<<"Jack Frost 67 77 87 88 86 89 96 "<<endl;
fout<<"Sleeping Beauty 90 89 78 88 86 85 93 "<<endl;
fout<<"Prince Charming 92 87 88 89 90 91 78 "<<endl;
fout<<"Rapunzel Repunzel 66 76 73 81 85 70 86 "<<endl;
fout<<"Santa Claus 90 89 95 86 88 94 99 "<<endl;
fout<<"Miss Horner 65 76 72 50 69 75 92 "<<endl;




while (fin)
{
fin>>firstName>>lastName>>prog1>>prog2>>prog3>>prog4>>prog5>>test1>>test2;
totalPoints = prog1+prog2+prog3+prog4+prog5+test1+test2;
progAvg = (prog1+prog2+prog3+prog4+prog5)/5;
testAvg = (test1+test2)/2;
totalAvg = (progAvg + testAvg)/2;
cout<<firstName<<" "<<lastName<<setw(20)<<totalPoints<<setw(10)<<progAvg<<setw(10)<<testAvg<<setw(10)<<totalAvg<<endl;
fout<<firstName<<" "<<lastName<<setw(20)<<totalPoints<<setw(10)<<progAvg<<setw(10)<<testAvg<<setw(10)<<totalAvg<<endl;


if (fin.peek() == '\n')fin.ignore();
}
cout<<setw(70)<<setfill('=')<<"="<<endl;
fout<<setw(70)<<setfill('=')<<"="<<endl;

fin.close();
fout.close();
cout<<"Press any key to quit...";
getch();


}




//A 90 - 100

//B 80 – 89

//C 70 - 79

//D 70-79

//Below 70 F
Last edited on
Please use code tags.

And you'll need to be more specific. What exactly isn't working?
Topic archived. No new replies allowed.