i nees to make a function to output students name in the form last name followed by a comma followed by a space followed by the first name and the name must be left justified than next to it need to print the student score and student grade like this:

Duckey, Dnoald 85 B
Goof, Goofy 89 B
i am able to do the name part but i am having problems alligning the test score and grade :
Duckey, Dnoald 85 B
Goof, Goofy 89 B
my code looks like this :

void printResult(studentType Student)
    int vectorSize = Student.testScore.size();
    cout << left << setw(10) << "Student Nmae " << right << setw(12) << "Test Score" << right << setw(12) 
         << "Grades" << endl;
    for (int i = 0; i < vectorSize; i++)
    cout <<  Student.studentLName[i]  <<  ", " 
	     <<  Student.studentFName[i] 
         << right << setw(30)<< Student.testScore[i]  << " " 
         << right << setw(30) << Student.grade[i] << endl;
9 Years
Discussion Span
Last Post by Lerner

I'd concatenate the name portions into a single string before output, then print that concatenated string with field width 30 (or whatever) left justified and fill with space char. Then output score with field width 3 right justifed and fill with space char and grade field width 2 right justified and fill with space char. That way students like me who get single digit grades will have score line up with the smarty pants.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.