// ------------------------------------------------------------------
// File name: grades.cpp
//
// Assign ID: PROG4
//
// Due Date: 2/21/12 at 11pm
//
// Purpose: Write a program to rearrange and format three lines of
// student data; data items are separated by whitespace.
//
//
// Author: bfields Byron Fields
//
// ------------------------------------------------------------------
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
//-| ----------------------------------------------------------------
//-| Declare Variables
//-| ----------------------------------------------------------------
long Student_ID; //-| Student's ID #
string FirstName; //-| Student's First Name
string LastName; //-| Student's Last Name
int CourseLoad; //-| Course Load
int CumHours; //-| Cumalative Hours
float GPA; //-| Student's GPA
//-| ----------------------------------------------------------------
//-| 1. Read data for the first student.
//-| ----------------------------------------------------------------
getline(cin, Student_ID+FirstName+Lastname+CourseLoad+CumHours+GPA);
//-| ----------------------------------------------------------------
//-| 2. Read data for the second student.
//-| ----------------------------------------------------------------
getline(cin, Student_ID+FirstName+Lastname+CourseLoad+CumHours+GPA)
//-| ----------------------------------------------------------------
//-| 3. Read data for the third student.
//-| ----------------------------------------------------------------
getline(cin, Student_ID+FirstName+Lastname+CourseLoad+CumHours+GPA)
//-| ---------------------------------------------------------------------
//-| 4. Write report headings.
//-| ---------------------------------------------------------------------
cout << "====" << " " << "=========" << " " << "====" << " " << "=====" << " " << "==============" << endl;
cout << " " << endl;
cout << " GPA" << " " << "StudentID" << " " << "Load" << " " << "Hours" << " " << "Student_Name " << endl;
cout << " " << endl;
cout << "====" << " " << "=========" << " " << "====" << " " << "=====" << " " << "==============" << endl;
cout << " " << endl;
//-| ---------------------------------------------------------------------
//-| 5. Write data for the first student.
//-| ---------------------------------------------------------------------
cout << right << setw(4) << fixed << setprecision(2) << GPA << right << setw(9) << Student_ID << right << setw(4) << CourseLoad << right << setw(5) << CumHours << left << FirstName << ", " << LastName << endl;
//-| ---------------------------------------------------------------------
//-| 6. Write data for the second student.
//-| ---------------------------------------------------------------------
cout << right << setw(4) << fixed << setprecision(2) << GPA << right << setw(9) << Student_ID << right << setw(4) << CourseLoad << right << setw(5) << CumHours << left << FirstName << ", " << LastName << endl;
//-| ---------------------------------------------------------------------
//-| 7. Write data for the third student
//-| ---------------------------------------------------------------------
cout << right << setw(4) << fixed << setprecision(2) << GPA << right << setw(9) << Student_ID << right << setw(4) << CourseLoad << right << setw(5) << CumHours << left << FirstName << ", " << LastName << endl;
cout << " " << endl;
//-| ----------------------------------------------------------------------
//-| 8. Write report footer.
//-| ----------------------------------------------------------------------
cout << "====" << " " << "=========" << " " << "====" << " " << "=====" << " " << "==============" << endl;
byron, you can actually manipulate strings just like an array. Barring that, use a stringstream to separate portions based on some kind of marker, like a space.
That's obviously not everything that's wrong with it, timmyyyyy. Look at how all three lines are identical to each other, and the names don't show up. Also, someone apparently has 112 1/2 credit hours, which shouldn't be possible.
Okay, byron. First thing you're doing is that you're copying over the top of your other values before you use those values. That's why you only have one output repeated three times. You need to either define an array to hold the information, or you need to use some sort of iteration to print them out as you receive them. In the case of your specific example, I'm thinking the array.
Second thing is that you're messing with the width on part of your output, but not all. This will cause (purely aesthetic) difficulties with formatting.
Third, a lot of the iomanip functions that you're using are going to screw up your other output. I would advise that if you have to use some sort of iomanip for something, that you should iomanip only exactly the same things on the same lines. This will help clear up what you're doing in your head, and make it easier to read. For example, if you need a precision of 2 on only the GPA, then make that it's own line (of code) and just don't move to the next line (of output) before you start putting out everything else.