In: Computer Science
Write a program to calculate fees that must be paid by a student at a State university using the following
values:
Each semester unit
$90.00
Regular room charge per semester
$200.00
Air conditioned room
$250.00
Food charge for the semester
$400.00
Matriculation fee (all students)
$30.00
Diploma fee (if graduating student)
$35.00
Input student ID number (one integer containing four digits), the type of room (regular or air conditioned), units, and whether or not the student is graduating. Output an itemized list of student
fees and a total of the student fee owed. Check for students taking more than 21 units and students
taking fewer than 12 units. Output a message to students enrolled in more than 21 units (this is not
allowed, do not process this data) or fewer than 12 units (warn them that they are not full time students
but do process this data).
Input
Three initials of the individual, student identification number, type of room (R, A), number of units, and
whether or not student is graduating (Y/N).
Sample
Output
Student ID
12345
Units
15
Charge for units
1350.00
Room charge
200.00
Food charge
400.00
Matriculation Fee
30.00
Total semester charges
1980.00
Adequately check all entered data for validity. Use adequate test data to process all valid data and use
representative data to show how your program handles invalid data. .
Label all output clearly.
Be sure your output contains user prompts and what was entered by the user in addition to the results
of your program processing.
BE SURE TO INCLUDE ADEQUATE ERROR CHECKING IN YOUR PROGRAM A
ND ERROR DATA WHEN YOU
RUN THE
PROGRAM TO DEMONSTRATE ERROR CHECKING.
Answer: Hello! Dear student, you didn't mention any particular language to design this program that's why i used here c++. This program is error-free and working well, giving the desired output as you have shown in the sample. If you have any queries, feel free to ask me. Thanks.
#include<iostream> //include header files
#include<stdlib.h>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
int id,count=0,unit; //int type variables
float
unit_charge=90.00,regularRoom_charge=200.00,AcRoom_charge=250.00,Food_charge=400.00,Matriculation_fee=30.00,Diploma_fee=35.00,total=0,
//float type variables declaration with initialization
room_charge=0,graduate_fee;
string room; //string type variable
char graduate; //char type variable
cout<<"Enter student ID: "<<endl;
//prompts for student id
cin>>id;
while(id!=0) //validation check for student id
{
id = id/10;
++count;
}
if(count<4) //if invalid
{
cout<<endl<<"Invalid
ID! ID should be has four digits";
exit(0);
}
cout<<endl<<"Enter the type of room
AC/Regular: "<<endl; //prompts for romm type
cin>>room;
if(room=="AC") //to check choice
{ room_charge = AcRoom_charge;
total = room_charge;
}
else
{ room_charge = regularRoom_charge;
total =room_charge;
}
cout<<endl<<"Enter the units of
semester"<<endl; //prompts for units
cin>>unit;
if(unit>21) //validation check for unit
{
cout<<endl<<"Students
enrolled more than 21 units. This is not allowed";
exit(0);
}
else
if(unit<12)
{
cout<<endl<<"Warning!!You are not full time students";
//warninh message
}
unit_charge =
unit*unit_charge; //calculate unit charge
total =
total+unit_charge;
cout<<endl<<"Are you
graduate?(Y/N)"<<endl; //prompt for graduate
cin>>graduate;
//print charges with items list , at last total charges
cout<<endl<<"Charges for
units:";
cout<<endl<<"$"<<fixed<<setprecision(2)<<unit_charge;
cout<<endl<<"Room charge:";
cout<<endl<<room_charge;
cout<<endl<<"Food charge:";
cout<<endl<<"$"<<Food_charge;
cout<<endl<<"Metriculation Fee:";
cout<<endl<<"$"<<Matriculation_fee;
if(graduate=='Y')
{ graduate_fee = Diploma_fee;
total = total+graduate_fee;
cout<<endl<<"Diploma
Fee: ";
cout<<endl<<"$"<<graduate_fee;
}
total = total+Matriculation_fee+Food_charge;
cout<<endl<<"Total Semester charges
:";
cout<<endl<<"$"<<total;
return 0;
}
Enter student ID: 1234 Enter the type of room AC/Regular: AC Enter the units of semester 15 Are you graduate? (Y/N) Y Charges for units: $1350.00 Room charge: 250.00 Food charge: $400.00 Metriculation Fee: $30.00 Diploma Fee: $35.00 Total Semester charges : $2065.00 US