Lining up text on display screen

28 views Asked by At

I created a GPA Calculator that displays a transcript-like visual after all of the proper variables have been input. I'm having trouble lining everything up in an efficient way. I currently use long empty strings to separate the variables, but it's not extremely efficient. Is there a function that can properly line up all of my text in the way that I want?

Here is a sample of the display.

Below is the code for printing the display.

void print(vector<string> className, vector<double> creditHours, vector<string> letterGrade, vector<double> letterValue, int classCount) {
    double gpa = calculate(letterGrade, letterValue, creditHours, classCount);

    cout << "\033[2J\033[1;1H"; // Flushes the screen

    cout << "************************************" << endl;
    cout << "Name          Weight          Grade" << endl << endl;

    //TODO Align all classes and numbers

    for (int i = 0; i < classCount; i++) {
            cout << className.at(i) << "            " << creditHours.at(i) << "               " << letterGrade.at(i) << endl;
    }

    cout << endl << "GPA: " << gpa << endl;
    cout << "************************************" << endl;
    cout << "(1) Rename Class  (2) Change Weight  (3) Change Grade   (4) Add Class  (5) Remove Class (6) Exit" << endl;
    cout << "What would you like to do: ";
}
0

There are 0 answers