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
|
#include <iostream>
#include <string>
using namespace std; // for the record I hate doing this
int main()
{
int studYear = 0, smithCnt = 0, johnCnt = 0;
int year1Cnt = 0, year2Cnt = 0, year3Cnt = 0, year4Cnt = 0;
int mathCnt = 0, CISCnt = 0, totalMathCnt = 0, totalCISCnt = 0;
double average = 0.0, studGpa = 0.0, mathGPASum = 0.0, CISGPASum = 0.0;
string studName, studMajor, studAdvisor, complete;
// read the data
do{
cout << "1-Freshman 2-Sophomore 3-Junior 4-Senior\n";
cout << "Enter 0 if no more students to input\n";
cout << "Enter year in school: ";
cin >> studYear;
if(studYear != 0){
if(studYear == 1){
year1Cnt++;
}else if(studYear == 2){
year2Cnt++;
}else if(studYear == 3){
year3Cnt++;
}else{
year4Cnt++;
}
cout << "Enter Student's name: ";
cin >> studName;
cout << "Math or CIS Major: ";
cin >> studMajor;
cout << "Enter students GPA: ";
cin >> studGpa;
if (studMajor == "Math"){
mathCnt++;
mathGPASum += studGpa;
totalMathCnt++;
}else{
CISCnt++;
CISGPASum += studGpa;
totalCISCnt++;
}
cout << "Enter sutdent advisor(Johnson or Smith): ";
cin >> studAdvisor;
if (studAdvisor[0] == 'J' || studAdvisor[0] == 'j'){
johnCnt++;
}else{
smithCnt++;
}
}
}while(studYear != 0);
cout << "Year 1 students: " << year1Cnt << endl;
cout << "Year 2 students: " << year2Cnt << endl;
cout << "Year 3 students: " << year3Cnt << endl;
cout << "Year 4 students: " << year4Cnt << endl;
cout << "Johnson has " << johnCnt << " students\n";
cout << "Smith has " << smithCnt << " students\n";
average = mathGPASum / totalMathCnt;
cout << "Math GPA: " << average << endl;
average = CISGPASum / totalCISCnt;
cout << "CIS GPA: " << average << endl;
return 0;
}
|
1-Freshman 2-Sophomore 3-Junior 4-Senior
Enter 0 if no more students to input
Enter year in school: 2
Enter Student's name: BHX
Math or CIS Major: CIS
Enter students GPA: 2.3
Enter sutdent advisor(Johnson or Smith): Smith
1-Freshman 2-Sophomore 3-Junior 4-Senior
Enter 0 if no more students to input
Enter year in school: 1
Enter Student's name: Joe
Math or CIS Major: Math
Enter students GPA: 4.0
Enter sutdent advisor(Johnson or Smith): Johnson
1-Freshman 2-Sophomore 3-Junior 4-Senior
Enter 0 if no more students to input
Enter year in school: 3
Enter Student's name: Dan
Math or CIS Major: Math
Enter students GPA: 2.1
Enter sutdent advisor(Johnson or Smith): Johnson
1-Freshman 2-Sophomore 3-Junior 4-Senior
Enter 0 if no more students to input
Enter year in school: 4
Enter Student's name: Bob
Math or CIS Major: CIS
Enter students GPA: 1.1
Enter sutdent advisor(Johnson or Smith): Smith
1-Freshman 2-Sophomore 3-Junior 4-Senior
Enter 0 if no more students to input
Enter year in school: 0
Year 1 students: 1
Year 2 students: 1
Year 3 students: 1
Year 4 students: 1
Johnson has 2 students
Smith has 2 students
Math GPA: 3.05
CIS GPA: 1.7 |