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 107 108 109 110 111 112 113 114 115 116 117
|
#include <iostream>
using namespace std;
int main()
{
char calc, parking, sticker, idcard, resident;
int credits, semester;
const double fs_parking = 85.00, ws_parking = 45.00,
fs_service = 50.50, ws_service = 47.50,
as_sticker = 19.50, id_card = 13.00,
resident_fee = 46.00, nonresident_fee = 295.00;
double fee;
do
{
cout << "Enter number of units enrolled:";
cin >> credits;
cout << "Is this Fall[0], Winter[1], Spring[2] or Summer[3] session:";
cin >> semester;
cout << "Are you a state resident[0] or not[1]:";
cin >> resident;
switch(resident)
{
case '0': fee = credits * resident_fee;
break;
case '1': fee = credits * nonresident_fee;
break;
default: cout << "You must enter 0, or 1\n";
} // end switch
cout << "Want a parking decal? [y/n]:";
cin >> parking;
switch(parking)
{
case 'y':
case 'Y':
if (semester = 0, 2)
{
fee = fee + fs_parking;
}
else if (semester = 1, 3)
{
fee = fee + ws_parking;
}
break;
case 'n':
case 'N': fee = fee;
break;
default: cout << "You must enter Y, or N\n";
} // end switch
cout << "Want an AS sticker? [y/n]:";
cin >> sticker;
switch(sticker)
{
case 'y':
case 'Y': fee = fee ;
case 'n':
case 'N': fee = fee - as_sticker;
break;
default: cout << "You must enter Y, or N\n";
} // end switch
cout << "Want an ID card? [y/n]:";
cin >> idcard;
switch(idcard)
{
case 'y':
case 'Y': fee = fee;
break;
case 'n':
case 'N': fee = fee - id_card;
break;
default: cout << "You must enter Y, or N\n";
} // end switch
if (semester == 0)
{
cout << "For Fall semester, your total fees are $ " << fee + fs_service << endl;
}
else if (semester == 1)
{
cout << "For Winter semester, your total fees are $ " << fee + ws_service << endl;
}
else if (semester == 2)
{
cout << "For Spring semester, your total fees are $ " << fee + fs_service << endl;
}
else if (semester == 3)
{
cout << "For Summer semester, your total fees are $ " << fee + ws_service << endl;
}
else
{
cout << "Error" << endl;
}
cout << "\nWould you like to do another calculation? Y or N: ";
cin >> calc;
} while( calc=='y' || calc=='Y' );
return 0;
}
|