In: Computer Science
can someone please check the code below? Thank you
Hunterville College Tuition
Design a program for Hunterville College. The current tuition is $20,000 per year. Allow the user to enter the rate the tuition increases each year. Display the tuition each year for the next 10 years.
For the programming problem, create the pseudocode and enter it below.
Enter pseudocode here
start
Declarations
num tuition
num year
num TOTAL_YEARS = 10
num INCREASE_RATE
num CURR_TUTION = 20000
housekeeping()
detailLoop()
finish()
stop
housekeeping( )
output “Enter rate the tuition will increase each year>”, INCREASE_RATE
return
detailLoop()
while year <= TOTAL_YEARS
tuition = tuition * (1 + INCREASE_RATE)
output “In”, TOTAL_YEARS, “year(s) the tuition will be”, tuition
year = year + 1
endwhile
return
finish()
output “End of program”
return
C++ program to display tutition fee for the next five years
Source code:
#include <iostream>
using namespace std;
class Tution{
public:
int year;
int fee=20000;
int rate;
int totalyears=10;
int totalfee;
void housekeeping(){
cout<<"Enter rate of increase per year: ";
cin>>rate;
cout<<"Total Years: "<<totalyears<<endl;
//totalfee=fee*rate;
//while (year <= totalyears){
totalfee = fee * (1 + rate);
year = year + 1;
cout<<"in "<<totalyears<<"years the total fee will be: "<<totalfee;
//}
}
int detailLoop(){
while (year <= totalyears){
totalfee = fee * (1 + rate);
year = year + 1;
cout<<"in"<<totalyears<<endl;
cout<<"The total fee will be: \n"<<totalfee<<endl;
//output “In”, TOTAL_YEARS, “year(s) the tuition will be”, tuition
}
//cout<<"Total fee for 10 years"<< totalfee;
}
void finish(){
cout<<"End of the program!!!";
}
};
int main(){
//Creating object of class Add
Tution myobj;
//asking for input
myobj.housekeeping();
//Displaying the output
myobj.detailLoop();
myobj.finish();
return 0;
}
The output
Enter rate of increase per year: 2
Total Years: 10
in 10years the total fee will be: 60000
End of the program!!!