Log in

View Full Version : Alignment Difficulties of my c++ program


chemengr12
Oct 26, 2009, 09:49 AM
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<<"01234567890123456789012345678901234567890123456789 0123456789"<<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<<"\n123456789012345678901234567890123456789012345678 9012345678901234567890"<<endl;

fout<<setw(10)<<setfill('=')<<endl;

cout<<setw(15)<<left<<"Student Name"<<setw(15)<<"Total"<<setw(15)<<"Program"<<setw(15)<<"Test"<<setw(15)<<"Course"<<setw(15)<<"Grade"<<endl;

cout<<setw(15)<<left<<" "<<setw(15)<<"Points"<<setw(15)<<"Average"<<setw(15)<<"Average"<<setw(15)<<"Average"<<setw(15)<<" "<<endl;

cout<<"--------------------------------------------------\n\n";

fout<<"\n123456789012345678901234567890123456789012345678 9012345678901234567890"<<endl;

fout<<setw(10)<<setfill('=')<<endl;

fout<<setw(15)<<left<<"Student Name"<<setw(15)<<"Total"<<setw(15)<<"Program"<<setw(15)<<"Test"<<setw(15)<<"Course"<<setw(15)<<"Grade"<<endl;

fout<<setw(15)<<left<<" "<<setw(15)<<"Points"<<setw(15)<<"Average"<<setw(15)<<"Average"<<setw(15)<<"Average"<<setw(15)<<" "<<endl;

fout<<"--------------------------------------------------\n\n";


while(fin){

fin>>fName>>lName>>prog1>>prog2>>prog3>>prog4>>prog5>>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)<<testAvg<<setw(10)<<courseAvg<<endl;

fout<<fName+" "+lName<<setw(10)<<left<<totalPoints<<setw(10)<<progAvg<<setw(10)<<testAvg<<setw(10)<<courseAvg<<endl;



if (fin.peek() == '\n')fin.ignore();

}

fin.close();

fout.close();



system("pause");

return 0;

}

yumbrad
Feb 12, 2010, 08:39 PM
What do you mean "alignment"... cout text alignment? Memory alignment of some sort? Describe the problem in more detail please.