Instructions : Use a while loop and loop following program for unknown numbers o
ID: 3606974 • Letter: I
Question
Instructions: Use a while loop and loop following program for unknown numbers of customers.
The Casewell Catering and Convention Service have asked you to write a computer program to produce customer’s bill. The program should read in the following data.
The number of adults to be served.
The number of children to be served.
The cost per adult’s meal.
The cost per child’s meal (60% of the cost of adult’s meal).
The cost for dessert (same for adults and children).
The room fee.
A percentage for tip and tax (not applicable to room fee).
Any deposit should be deducted from the room fee.
You program will produce following output:
Casewell Catering and Convention Service
Final Bill
Number of Adults: 23
Number of Children: 7
Cost per adult without dessert: $ 12.75
Cost per child without dessert: $ 7.65
Cost per dessert: $ 1.00
Room fee: $ 45.00
Tip and tax rate: 0.18
Total cost for adult meals: $ 239.25
Total cost for child meals: $ 53.55
Total cost for dessert: $ 30.00
Total food cost: $ 376.80
Plus tips and tax: $ 67.82
Plus room fee: $ 45.00
Less deposit: $ 50.00
Balance due: $ 439.62
Explanation / Answer
#include<stdio.h>
#include<stdlib.h>
int main()
{
int ch = 1 ;
int m , n ;
float p,q,r,s,d;
while(ch)
{
printf(" Number of Adults: ");
scanf("%d",&m);
printf(" Number of Children: ");
scanf("%d",&n);
printf(" Cost per adult without dessert: $ ");
scanf("%f",&p);
printf(" Cost per children without dessert: $ %f",p*0.60);//60% of the adult
printf(" Cost for dessert:(same for both child and adult $ ");
scanf("%f",&q);
printf(" Room fee: $ ");
scanf("%f",&r);
printf("Tip and tax rate : ") ;
scanf("%f",&s);
printf(" Total cost for adult meals: $ %f ",m*p);
printf(" Total cost for child meals: $ %f ",n*p*0.60);
printf(" Total cost for dessert: $ %f ",(m+n)*q);
float total = m*p+n*p*0.60+(m+n)*q;
float l;//less deposit
printf(" Total food cost: $ %f",total);
printf(" Plus tips and tax: $ %f",total*s);
printf(" Plus room fee: $ %f",r);
printf(" Enter Less deposit: $ %f",d);
scanf("%f",&l);
printf(" Balance due : $ %f", (total+total*s-d)-l);
printf(" Do you want to continue ? Enter 0 to exit else enter any value ");
scanf("%d",&ch);
}
return 0;
}