Question
Hello, I'm trying to write a program that asks for hotel reservations including the kind of room, King, Queen, and Double as well as how
#include
char convert(char typer, int rentr){
switch(typer){
case 'K':
rentr=79;
break;
case 'Q':
rentr=69;
break;
case 'D':
rentr=59;
break;
default:
printf("Error");
}
return rentr;
}
int calc(int numb, int rentr){
if(numb==1){
rentr;
}
else if(numb==2){
rentr = 0.85*rentr;
}
else if(numb==3){
rentr = 0.85*rentr;
}
else{
rentr = 0.70*rentr;
}
return rentr;
}
int main(){
int num, num2;
int rent = 0, rent2 = 0;
int total, total2;
char rtype, rtype2;
printf("Enter the room type(K/Q/D) ");
scanf("%c", &rtype);
getchar();
printf("Enter the number of days of stay ");
scanf("%d", &num);
rent = convert(rtype, rent);
rent = calc(num, rent);
printf("Enter the room type(K/Q/D) ");
scanf("%c", &rtype2);
getchar();
printf("Enter the number of days of stay ");
scanf("%d", &num2);
rent2 = convert(rtype2, rent2);
rent2 = calc(num2, rent2);
printf("Total= $%d ", rent);
printf("Total= $%d ", rent2);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started