I'm having a problem on try again program.I checked the syntax and yet is still not working.am trying to make a program that will output the student's grade and when the program is finished it will ask whether to try again or not.If the input is y or Y, the program will repeat all over again.
p.s:it must be on do while loop on choice 4.
Here's the code:
#include <iostream>
using namespace std;
main()
{
const int size=4;
int choice[size];
int q1,q2,qT,exam,stand;
double ave;
char exit,again;
char y,n;
cout<<"Grade Computation"<<endl;
cout<<"Select Choice:"<<endl;
cout<<"1.Prelim Grade"<<endl;
cout<<"2.Midterm Grade"<<endl;
cout<<"3.Final Grade"<<endl;
cout<<"4.Exit"<<endl;
cout<<endl;
system("pause");
cout<<"Enter choice[1-4]:";
cin>>choice[size];
do
{
switch(choice[size])
{
case 1:
cout<<"Enter Quiz 1:";
cin>>q1;
cout<<"Enter Quiz 2:";
cin>>q2;
qT=q1+q2;
qT=qT / 2;
cout<<endl<<"Quiz Average:"<<qT;
cout<<endl<<"Prelim Exam:";
cin>>exam;
cout<<"Class Standing:";
cin>>stand;
ave=qT *.40 + stand *.10 + exam *.50;
cout<<endl<<"Prelim Grade:"<<ave;
cout<<endl<<"Try again?[y/n]:";
cin>>again;
while(again=='y')
{
cin>>choice[size];
}
if(again=='n')
cout<<"goodbye!!";
break;
case 2:
cout<<"Enter Quiz 1:";
cin>>q1;
cout<<"Enter Quiz 2:";
cin>>q2;
qT=q1+q2;
qT=qT / 2;
cout<<endl<<"Quiz Average:"<<qT;
cout<<endl<<"Midterm Exam:";
cin>>exam;
cout<<endl<<"Class Standing:";
cin>>stand;
ave=qT *.40 + stand *.10 + exam *.50;
cout<<endl<<"Midterm Grade:"<<ave;
cout<<endl<<"Try again?[y/n]:";
cin>>again;
while(again=='y')
{
cin>>choice[size];
}
if(again=='n')
cout<<"goodbye!!";
break;
case 3:
cout<<"Enter Quiz 1:";
cin>>q1;
cout<<"Enter Quiz 2:";
cin>>q2;
qT=q1+q2;
qT=qT / 2;
cout<<endl<<"Quiz Average:"<<qT;
cout<<endl<<"Midterm Exam:";
cin>>exam;
cout<<endl<<"Class Standing:";
cin>>stand;
ave=qT *.40 + stand *.10 + exam *.50;
cout<<endl<<"Midterm Grade:"<<ave;
cout<<endl<<"Try again?[y/n]:";
cin>>again;
system("pause");
while(again=='y')
{
cin>>choice[size];
}
if(again=='n')
cout<<"goodbye!!";
break;
case 4:
cout<<"Are you sure you want to exit[y/n]:";
cin>>exit;
}
while(exit=='n');
cout<<"goodbye!";
break;
}
}