I HAVE DONE UPTO THIS.BUT I NEED TO FIND THE AVERAGE OF UNDERGRADUATE STUDENTS MARKS.PLEASEE HELP ME
#include <iostream>
#include <string>
using namespace std;
int main()
{
int choice;
// Display the menu
cout<<"\n\t\Welcome to the GPA calculator ! \n\n"
<<"1. Undergraduate GPA calculator\n"
<<"2. Graduate GPA calculator\n"
<<"3. How saved records\n"
<<"4. quit\n"
<<"enter a choice\n";
cin>>choice;
string name;
int course;
int id;
int ccode[5];
int chrs[5];
int cgrade[5];
int gccode[5];
int gchrs[5];
int gcgrade[5];
switch (choice)
{
case 1:
cout<<"Undergraduate GPA calculation \n";
cout<<"Enter your name\n";
cin>>name;
cout<<endl;
cout<<"Enter your Id\n";
cin>>id;
cout<<endl;
cout<<"Enter number of courses\n";
cin>>course;
//string cname;
for (int i=1; i<=course;i++)
{
cout<< "Getting course information for course"<<i<<endl;
cout<<"Enter course name"<<endl;
cin>>cname;
cout<<endl;
cout<<"Enter course code"<<endl;
cin>>ccode[i];
cout<<endl;
cout<<"Enter course crdt hrs"<<endl;
cin>>chrs[i];
cout<<endl;
cout<<"Enter course grade(0-100%)"<<endl;
cin>>cgrade[i];
cout<<endl;
}
break;
case 2:
cout<<"graduate GPA calculation \n";
cout<<"Enter your name\n";
cin>>name;
cout<<endl;
cout<<"Enter your Id\n";
cin>>id;
cout<<endl;
cout<<"Enter number of courses\n";
cin>>course;
//string cname;
for (int i=1; i<=course;i++)
{
cout<< "Getting course information for course"<<i<<endl;
cout<<"Enter course name"<<endl;
cin>>cname;
cout<<endl;
cout<<"Enter course code"<<endl;
cin>>gccode[i];
cout<<endl;
cout<<"Enter course crdt hrs"<<endl;
cin>>gchrs[i];
cout<<endl;
cout<<"Enter course grade(0-100%)"<<endl;
cin>>gcgrade[i];
cout<<endl;
}
break;
}
return 0;
}
Hi Jihan,
for better readability please use "<>"(Source Code icon) to format the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
int choice;
// Display the menu
cout<<"\n\tWelcome to the GPA calculator ! \n\n"
<<"1. Undergraduate GPA calculator\n"
<<"2. Graduate GPA calculator\n"
<<"3. How saved records\n"
<<"4. quit\n"
<<"enter a choice\n";
cin>>choice;
string name;
string cname;
int course;
int id;
int ccode[5];
int chrs[5];
int cgrade[5];
int gccode[5];
int gchrs[5];
int gcgrade[5];
int sum = 0;
switch (choice)
{
case 1:
cout<<"Undergraduate GPA calculation \n";
cout<<"Enter your name\n";
cin>>name;
cout<<endl;
cout<<"Enter your Id\n";
cin>>id;
cout<<endl;
cout<<"Enter number of courses\n";
cin>>course;
for (int i=1; i<=course;i++)
{
cout<< "Getting course information for course"<<i<<endl;
cout<<"Enter course name"<<endl;
cin>>cname;
cout<<endl;
cout<<"Enter course code"<<endl;
cin>>ccode[i];
cout<<endl;
cout<<"Enter course crdt hrs"<<endl;
cin>>chrs[i];
cout<<endl;
cout<<"Enter course grade(0-100%)"<<endl;
int tempValue = 0;
cin>>cgrade[i];
tempValue = cgrade[i];
sum = sum + tempValue;
cout<<endl;
}
break;
case 2:
cout<<"graduate GPA calculation \n";
cout<<"Enter your name\n";
cin>>name;
cout<<endl;
cout<<"Enter your Id\n";
cin>>id;
cout<<endl;
cout<<"Enter number of courses\n";
cin>>course;
//string cname;
for (int i=1; i<=course;i++)
{
cout<< "Getting course information for course"<<i<<endl;
cout<<"Enter course name"<<endl;
cin>>cname;
cout<<endl;
cout<<"Enter course code"<<endl;
cin>>gccode[i];
cout<<endl;
cout<<"Enter course crdt hrs"<<endl;
cin>>gchrs[i];
cout<<endl;
cout<<"Enter course grade(0-100%)"<<endl;
int tempValue = 0;
cin>>gcgrade[i];
tempValue = gcgrade[i];
sum = sum + tempValue;
cout<<endl;
}
break;
}
if (choice == 1 ){
cout << "Sum of entered values : " << sum << endl;
cout << "Averag of entered values : " << sum / course << endl;
}
if (choice == 2 ){
cout << "Sum of entered values : " << sum << endl;
cout << "Averag of entered values : " << sum / course << endl;
}
return 0;
}
| |
Last edited on