Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

What is conservative approach ?

Answered: 1 week ago