Make a program that will input type of accommodation room. A-for first class, B-for second
class. Charge as follows : first class=800.00 and second class = 650.00. Your program will be
terminated if you input C in the accommodation room type.
SOLUTION TO THE ABOVE QUESTION
SOLUTION CODE
#include<iostream>
using namespace std;
int main()
{
string terminate_condition = "";
while(terminate_condition!="C")
{
//propmt the user to enter the room A or B
cout<<"\nEnter room type: ";
string room_type;
cin>>room_type;
//update terminate condition
terminate_condition = room_type;
if(room_type=="A")
{
cout<<"Room type A, first class room."<<endl;
cout<<"The charges are 800.00"<<endl;
}
else if(room_type=="B")
{
cout<<"Room type B, second class room."<<endl;
cout<<"The charges are 650.00"<<endl;
}
else
{
if(terminate_condition=="C")
{
cout<<"Program successfully exited"<<endl;
}
else
{
cout<<"Invalid room type, please try again"<<endl;
}
}
}
return 0;
}
SAMPLE PROGRAM OUTPUT
Comments
Leave a comment