Answer to Question #262697 in C++ for punisher

Question #262697

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.


1
Expert's answer
2021-11-08T05:32:23-0500


SOLUTION FOR 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 OUTPUT PROGRAM






Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS