Write a C++ program to store 10 student names and grade point averages (GPAs) fr
ID: 3795576 • Letter: W
Question
Write a C++ program to store 10 student names and grade point averages (GPAs) from the user. Display all student information in a tabular format. Ensure that each column heading aligns correctly with its respective column and that each name (first and last) is capitalized. Finally, display each GPA with two significant decimals. Sample inputs and outputs are as follows: Sample Input (for only 3 students) Smith, Tom 4.0 Jones, Bob 5.555 Washington, George 3.00 Sample Output (using input above) Name (Last, First) GPA Smith, Tom 4.00 Jones, Bob 5.56 Washington, George 3.00
Explanation / Answer
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
int main()
{
char mark [4][12];
float pmark[4], pngk;
cout<<"This Program Will Calculate Your CGPA for subject SK026, QS025,"
<<" SB026 and SC025."<<endl;
cout<<"You should enter your grade only."<<endl<<endl;
cout<<"Please enter your result :"<<endl<<endl;
cout<<"MATHEMATIC : ";
cin>>mark[0];
cout<<endl;
cout<<"CHEMISTRY : ";
cin>>mark[1];
cout<<endl;
cout<<"BIOLOGY : ";
cin>>mark[2];
cout<<endl;
cout<<"SCIENCE COMPUTER : ";
cin>>mark[3];
cout<<endl;
for (int a=0; a<4; a++)
{
if (strcmp("A", mark[a]) == 0)
pmark[a]=4.0;
else if (strcmp("A-", mark[a]) == 0)
pmark[a]=3.67;
else if (strcmp("B+", mark[a]) == 0)
pmark[a]=3.33;
else if (strcmp("B", mark[a]) == 0)
pmark[a]=3.00;
else if (strcmp("B-", mark[a]) == 0)
pmark[a]=2.67;
else if (strcmp("C+", mark[a]) == 0)
pmark[a]=2.33;
else if (strcmp("C", mark[a]) == 0)
pmark[a]=2.00;
else if (strcmp("D+", mark[a]) == 0)
pmark[a]=1.67;
else if (strcmp("E", mark[a]) == 0)
pmark[a]=1.00;
else
pmark[a]=0;
}
cout<<endl<<endl;
cout<<"Result MATHEMATIC ="<<" "<<mark[0]<<" ----->"<<" "<<pmark[0]<<endl;
cout<<"Result CHEMISTRY ="<<" "<<mark[1]<<" ----->"<<" "<<pmark[1]<<endl;
cout<<"Result BIOLOGY ="<<" "<<mark[2]<<" ----->"<<" "<<pmark[2]<<endl;
cout<<"Result SCIENCE COMPUTER ="<<" "<<mark[3]<<" ----->"<<" "<<pmark[3]<<endl;
pngk=((pmark[1]*6)+(pmark[2]*6)+(pmark[0]*5)+(pmark[3]*5))/22;
cout<<endl<<endl;
cout<<"Your PNGK is : "<<pngk<<endl;
cin.get();
system ("PAUSE");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.