/* PROGRAM output formatting samples AUTHOR: FSU ID: COURSE INFORMATION: COP 3014 Recitation Number: 2 SUMMARY Print out a table with required outpput formats. INPUT N/A OUTPUT A table with required outpput formats. DATA STRUCTURES N/A ASSUMPTIONS N/A */ #include #include #include using namespace std; int main() { /************* Variable declaration *************/ const char BLANK = ' '; // storage for a blank space string stud_name_1 = "Alice", // storage for the name of the first student stud_name_2 = "Bob", // storage for the name of the second student stud_name_3 = "Cherry"; // storage for the name of the third student double proj1_score_1 = 100, // storage for the score of the first student in project 1 proj1_score_2 = 75.5, // storage for the score of the second student in project 1 proj1_score_3 = 72.5, // storage for the score of the third student in project 1 proj2_score_1 = 89, // storage for the score of the first student in project 2 proj2_score_2 = 79, // storage for the score of the second student in project 2 proj2_score_3 = 69; // storage for the score of the third student in project 2 double proj_average_score_1, // storage for the average score of the first student proj_average_score_2, // storage for the average score of the second student proj_average_score_3, // storage for the average score of the third student proj1_average_score, // storage for the average score of project 1 proj2_average_score, // storage for the average score of project 2 proj_average_score; // storage for the average score of all the projects char gpa_1, // storage for the GPA of the first student gpa_2, // storage for the GPA of the second student gpa_3; // storage for the GPA of the third student /************* Algorithm *************/ // calculate the average score of the each student proj_average_score_1 = (proj1_score_1 + proj2_score_1)/2; proj_average_score_2 = (proj1_score_2 + proj2_score_2)/2; proj_average_score_3 = (proj1_score_3 + proj2_score_3)/2; // calculate the average score of each project proj1_average_score = (proj1_score_1 + proj1_score_2 + proj1_score_3)/3; proj2_average_score = (proj2_score_1 + proj2_score_2 + proj2_score_3)/3; // calculate the average score of all the projects proj_average_score = (proj_average_score_1 + proj_average_score_2 + proj_average_score_3)/3; // calculate the GPA /************* Output *************/ cout << "==================================================" << endl; cout << '|' << setw(48) << BLANK << '|' << endl; cout << '|' << setw(18) << BLANK << "Grade Report" << setw(18) << BLANK << '|' << endl; cout << '|' << setw(48) << BLANK << '|' << endl; cout << "==================================================" << endl; /***************************************************************************************************/ /********************************** Modify below this line *****************************************/ /***************************************************************************************************/ cout << left; cout << '|' << setw(10) << "NAME"; cout << right; cout << '|' << setw(10) << "Proj 1" << '|' << setw(10) << "Proj 2"; cout << '|' << setw(10) << "Average" << '|' << setw(4) << "GPA" << '|' << endl; cout << "--------------------------------------------------" << endl; // report for the first student cout << '|' << stud_name_1; cout << '|' << proj1_score_1 << '|' << proj2_score_1; cout << '|' << proj_average_score_1 << '|' << BLANK << '|' << endl; cout << "--------------------------------------------------" << endl; // report for the second student cout << '|' << stud_name_2; cout << '|' << proj1_score_2 << '|' << proj2_score_2; cout << '|' << proj_average_score_2 << '|' << BLANK << '|' << endl; cout << "--------------------------------------------------" << endl; // report for the third student cout << '|' << stud_name_3; cout << '|' << proj1_score_3 << '|' << proj2_score_3; cout << '|' << proj_average_score_3 << '|' << BLANK << '|' << endl; cout << "==================================================" << endl; // report for average score in each column cout << '|' << "AVERAGE"; cout << '|' << proj1_average_score << '|' << proj2_average_score; cout << '|' << proj_average_score << '|' << '|' << endl; cout << "==================================================" << endl; cout << endl << endl; return(0); } // main function