Alignment Difficulties of my c++ program
The program is already right but it has some alignment issues and I cannot figure out how to fix it and I tried everything! If anyone could, can I please get some help before 12 am Tuesday, it will be greatly appreciated? This is the program:
//IT 210 Business Applications with C++
//Programmer: Aristio Alston
//Date: 10/20/09
//Program Assignment 2: Student Grades II
#include<iostream>
#include<iomanip>
#include<conio.h>
#include<fstream>
using namespace std;
int main(){
system("color f0");
cout<<"0123456789012345678901234567890123456789012 34567890123456789"<<endl;
cout<<"******************************************* *****************"<<endl;
cout<<"* IT 210 Business Applications with C++ *"<<endl;
cout<<"* Programmer: Aristio Alston *"<<endl;
cout<<"* Date: October 20, 09 *"<<endl;
cout<<"* *"<<endl;
cout<<"* Program Assignment 2: Student Grades II *"<<endl;
cout<<"* *"<<endl;
cout<<"* This program reads student information from *"<<endl;
cout<<"* an input text file and outputs the results *"<<endl;
cout<<"* to the monitor as well as to a text file *"<<endl;
cout<<"* *"<<endl;
cout<<"******************************************* *****************"<<endl;
cout<<endl;
cout<<"Welcome to the IT210 Grade Calculator!"<<endl<<endl;
cout<<"Examine the output file now before you proceed!"<<endl<<endl;
cout<<"Press any key to read input and calculate the grades of all students\n";
getch();
ifstream fin;
ofstream fout;
int prog1, prog2, prog3, prog4, prog5;
int test1, test2;
int totalPoints;
string fName, lName;
float progAvg, testAvg, courseAvg;
fin.open("input.txt");
if(!fin){
cout<<"Input failure\n";
system("pause");
return 1;
} //end of enclosure
fout.open("output.txt");
if(!fout){
cout<<"Output failure\n";
system("pause");
return 1;
} // end of error check
cout<<"\n12345678901234567890123456789012345678901 23456789012345678901234567890"<<endl;
fout<<setw(10)<<setfill('=')<<endl;
cout<<setw(15)<<left<<"Student Name"<<setw(15)<<"Total"<<setw(15)<<"Program"<<set w(15)<<"Test"<<setw(15)<<"Course"<<setw(15)<<"Grad e"<<endl;
cout<<setw(15)<<left<<" "<<setw(15)<<"Points"<<setw(15)<<"Average"<<setw(1 5)<<"Average"<<setw(15)<<"Average"<<setw(15)<<" "<<endl;
cout<<"--------------------------------------------------\n\n";
fout<<"\n12345678901234567890123456789012345678901 23456789012345678901234567890"<<endl;
fout<<setw(10)<<setfill('=')<<endl;
fout<<setw(15)<<left<<"Student Name"<<setw(15)<<"Total"<<setw(15)<<"Program"<<set w(15)<<"Test"<<setw(15)<<"Course"<<setw(15)<<"Grad e"<<endl;
fout<<setw(15)<<left<<" "<<setw(15)<<"Points"<<setw(15)<<"Average"<<setw(1 5)<<"Average"<<setw(15)<<"Average"<<setw(15)<<" "<<endl;
fout<<"--------------------------------------------------\n\n";
while(fin){
fin>>fName>>lName>>prog1>>prog2>>prog3>>prog4>>pro g5>>test1>>test2;
totalPoints = (prog1 + prog2 + prog3 + prog4 + prog5) + (test1 + test2);
progAvg = (prog1 + prog2 + prog3 + prog4 + prog5)/5.0;
testAvg = (test1 + test2)/2.0;
courseAvg = (progAvg + testAvg)/2.0;
cout<<fName +" "+ lName<<setw(10)<<left <<totalPoints<<setw(10)<<progAvg<<setw(10)<<testAv g<<setw(10)<<courseAvg<<endl;
fout<<fName+" "+lName<<setw(10)<<left<<totalPoints<<setw(10)<<pr ogAvg<<setw(10)<<testAvg<<setw(10)<<courseAvg<<end l;
if (fin.peek() == '\n')fin.ignore();
}
fin.close();
fout.close();
system("pause");
return 0;
}
|