In C The University of Ohio at Dayton determines yearly lab

In C++,

The University of Ohio at Dayton determines yearly lab dues as follows :

Class Level   GPA     Dues Amount
F (Firstyear)   -   $150
S (Second year)   Greater than 3.75   $75
S (Second year)   Greater than >2.50 && less than 3.75   $120
S (Second year)   Less than 2.5   $130
J (Junior)   Greater than 3.75   $50
J (Junior)   Greater than >2.50 && less than 3.75   $100
J (Junior)   Less than 2.5   $125
N (Senior)   Greater than 3.75   $25
N (Senior)   Less than 3.75   $75


For example, a Junior level student named Janice Morgan with a GPA = 3.81, is charged
yearly dues of $50. The program would output :

Janice Morgan/Junior/GPA=3.81 Dues are $50.00
  
Notes :

1.   User is to be prompted for student name, class level and GPA.
2.   The program must use a switch statement to interrogate the class level.
3.   The default case must be included. It outputs an the error message :

INVALID CLASS ENTERED !

4.   Within a case, use an if statement to test the GPA to determine the dues amount.

Solution

#include<iostream>
using namespace std;
int main()
{
string stuName;
char classL;
float GPA;
//Accept data
cout<<\"\ Enter Student name: \";
cin>>stuName;
cout<<\"\ Enter Student Class Level: \";
cin>>classL;
cout<<\"\ Enter Student GPA: \";
cin>>GPA;
//Checks class Level
switch(classL)
{
case \'F\':
case \'f\':
cout<<stuName<<\"/\"<<\"First Year\"<<\"/\"<<\"GPA = \"<<GPA<<\"\\t\"<<\" Dues are $\"<<150.00;
break;
case \'S\':
case \'s\':
//Checks GPA
if(GPA > 3.75)
cout<<stuName<<\"/\"<<\"Second Year\"<<\"/\"<<\"GPA = \"<<GPA<<\"\\t\"<<\" Dues are $\"<<75.00;
else if(GPA > 2.50 && GPA < 3.75)
cout<<stuName<<\"/\"<<\"Second Year\"<<\"/\"<<\"GPA = \"<<GPA<<\"\\t\"<<\" Dues are $\"<<120.00;
else
cout<<stuName<<\"/\"<<\"Second Year\"<<\"/\"<<\"GPA = \"<<GPA<<\"\\t\"<<\" Dues are $\"<<130.00;
break;
case \'J\':
case \'j\':
if(GPA > 3.75)
cout<<stuName<<\"/\"<<\"Junior\"<<\"/\"<<\"GPA = \"<<GPA<<\"\\t\"<<\" Dues are $\"<<50.00;
else if(GPA > 2.50 && GPA < 3.75)
cout<<stuName<<\"/\"<<\"Junior\"<<\"/\"<<\"GPA = \"<<GPA<<\"\\t\"<<\" Dues are $\"<<100.00;
else
cout<<stuName<<\"/\"<<\"Junior\"<<\"/\"<<\"GPA = \"<<GPA<<\"\\t\"<<\" Dues are $\"<<125.00;
break;
case \'N\':
case \'n\':
if(GPA > 3.75)
cout<<stuName<<\"/\"<<\"Senior\"<<\"/\"<<\"GPA = \"<<GPA<<\"\\t\"<<\" Dues are $\"<<25.00;
else
cout<<stuName<<\"/\"<<\"Senior\"<<\"/\"<<\"GPA = \"<<GPA<<\"\\t\"<<\" Dues are $\"<<75.00;
break;
default:
//Error for Invalid class
cout<<\"Error: INVALID CLASS ENTERED !\";
}
}

Output 1:

Enter Student name: Pyari

Enter Student Class Level: f

Enter Student GPA: 4.1
Pyari/First Year/GPA = 4.1 Dues are $150

Output 2:

Enter Student name: Mohan

Enter Student Class Level: s

Enter Student GPA: 4.1
Mohan/Second Year/GPA = 4.1 Dues are $75

Output 3:

Enter Student name: Ram

Enter Student Class Level: s

Enter Student GPA: 2.8
Ram/Second Year/GPA = 2.8 Dues are $120

Output 4:

Enter Student name: Sita

Enter Student Class Level: s

Enter Student GPA: 1.8
Sita/Second Year/GPA = 1.8 Dues are $130

In C++, The University of Ohio at Dayton determines yearly lab dues as follows : Class Level GPA Dues Amount F (Firstyear) - $150 S (Second year) Greater than 3
In C++, The University of Ohio at Dayton determines yearly lab dues as follows : Class Level GPA Dues Amount F (Firstyear) - $150 S (Second year) Greater than 3

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site