Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void) {
- float finalCost, InitialCost;
- int boo, foo, extra=0, number_of_people;
- printf("How many people are going to be staying in the room? ");
- scanf("%d", &number_of_people);
- if (number_of_people>4)
- extra=number_of_people-4;
- number_of_people=number_of_people-extra;
- switch (number_of_people){
- case 2:
- InitialCost=85;
- break;
- case 3:
- InitialCost=90;
- break;
- case 4:
- InitialCost=95;
- break;
- default:
- printf("This number of people is invalid. Please remember that the minimum is 2\n");
- return 0;
- }
- finalCost=InitialCost+(extra*6);
- over60:
- printf("Is the customer over 60? Type 1 for yes, 0 for no\n");
- scanf("%d", &boo);
- if (boo==1)
- finalCost=finalCost*0.85;
- else if (boo==0)
- {
- company:
- printf("Is the customer staying on company business? Type 1 for yes, 0 for no\n");
- scanf("%d", &foo);
- if (foo==1)
- finalCost=finalCost*0.8;
- else if (foo!=0)
- {
- printf("You have entered a wrong number. Try again:\n");
- goto company;
- }
- }
- else
- {
- printf("You have entered a wrong number. Try again:\n");
- goto over60;
- }
- printf("The cost for the room is: %.2f\n", finalCost);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement