Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- string name;
- string matric_no, code;
- int subject, credit ,cnt ,sum_credit=0;
- float gpa_sum=0, gpa_avrg;
- char grade,choice;
- bool choice_bool=true;
- while(choice_bool==true)
- {
- cout<<"Name: ";
- getline(cin,name);
- cout<<"Matrics No: ";
- cin>>matric_no;
- cout<< "How many subjects that you have taken: ";
- cin>>subject;
- cout<<endl;
- cout<<"=============================================="<<endl;
- cout<<"EXAMINATION RESULT SEMESTER I SESION 2017/2018"<<endl;
- cout<<"=============================================="<<endl;
- cout<<"NAME: "<<name<<endl;
- cout<<"MATRIC NO :"<<matric_no<<endl;
- cout<< fixed<<setprecision(1);
- cnt=1;
- while(cnt<=subject)
- {
- cout<<"SUBJECT "<<"["<<cnt<<"]"<<endl;
- cout<<"CODE: ";cin>>code;
- cout<<"CREDIT: "; cin>>credit;
- sum_credit=sum_credit+credit;
- cout<<"GRADE: ";cin>>grade;
- while(grade!='A'&& grade!='B'&& grade!='C'&& grade!='D')
- {
- cout<<"**INVALID GRADE**"<<endl;
- cout<<"GRADE: "<<endl; cin>>grade;
- }
- switch(grade)
- {
- case 'A': cout<<"POINT VALUE: 4"<<endl<<endl;
- grade=4;
- gpa_sum=gpa_sum+grade;
- break;
- case 'B': cout<<"POINT VALUE: 3"<<endl<<endl;
- grade=3;
- gpa_sum=gpa_sum+grade;
- break;
- case 'C': cout<<"POINT VALUE: 2"<<endl<<endl;
- grade=2;
- gpa_sum=gpa_sum+grade;
- break;
- case 'D': cout<<"POINT VALUE: 1"<<endl<<endl;
- grade=1;
- gpa_sum=gpa_sum+grade;
- break;
- }
- cnt++;
- }
- gpa_avrg=gpa_sum/subject;
- cout<<endl;
- cout<<"=============================================="<<endl;
- cout<<"TOTAL POINT VALUE: "<<sum_credit<<endl;
- cout<<"GPA: "<<gpa_avrg<<endl;
- cout<<"=============================================="<<endl;
- cout<<"Do you want to continue [Y to continue]"<<endl;
- cin>>choice;
- if (choice=='y')
- choice_bool=true;
- else
- choice_bool=false;
- cin.ignore(256, '\n');
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement