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

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 many nights. 2-3 nights stayed means a 15% discount, with anything above 4 nights stay being a 30% discount. My current program compiles, but the numbers are completely off. Could I get some help with this program? It'll be below.

#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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!