#include #define QUIT 5 #define HOTEL1 50.00 #define HOTEL2 55.00 #define HOTEL3 80.00 #define HOTEL4 100.00 #define DISCOUNT 0.95 #define STARS "***************" int menu(void); int getnights(void); void showprice(double,int); int main(void) { int nights; double hotel; int code; while((code=menu())!=QUIT) { switch(code) { case 1: hotel=HOTEL1; break; case 2: hotel=HOTEL2; break; case 3: hotel=HOTEL3; break; case 4: hotel=HOTEL4; break; default: hotel=0.0; printf("0OPS!\n"); } break; nights=getnights(); showprice(hotel,nights); } return 0; } int menu(void) { int code,status; printf("\n%s%s\n",STARS,STARS); printf("Enter the number of the desired hotel:\n"); printf("1)fairfileld Arms 2)Hotel Olympic\n"); printf("3)Chertworthy Plaza 4)The Stockton\n"); printf("5)quit\n"); printf("%s%s\n",STARS,STARS); while((status=scanf("%d",&code))!=1 || (code<1 ||code>5)) { if (status!=1) scanf("%*s"); printf("Enter an inter 1-5\n"); } return code; } int getnights(void) { int nights; printf("How many nights are needed?"); while(scanf("%d",&nights)!=1) { scanf("%*s"); printf("Please enter an integer, such as 2.\n"); } return nights; } void showprice(double hotel,int nights) { int n; double total=0.0; double factor=1.0; for(n=1;n<=nights;n++,factor*=DISCOUNT) total+=hotel*factor; printf("The total cost will be $%0.2f.\n",total); }