-
Notifications
You must be signed in to change notification settings - Fork 1
/
lobby2.c
48 lines (48 loc) · 841 Bytes
/
lobby2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* Theater lobby snack bar program */
#include <stdio.h>
int main()
{
char c;
int done;
float total=0;
printf("Please make your treat selections:\n");
printf("1 - Beverage.\n");
printf("2 - Candy.\n");
printf("3 - Hot dog.\n");
printf("4 - Popcorn.\n");
printf("= - Done.\n");
printf("Your choices:\n");
/* Figure out what they typed in. */
done=0;
while(!done)
{
c=getchar();
switch(c)
{
case '1':
printf("Beverage\t$8.00\n");
total+=8;
break;
case '2':
printf("Candy\t\t$5.50\n");
total+=5.5;
break;
case '3':
printf("Hot dog\t\t$10.00\n");
total+=10;
break;
case '4':
printf("Popcorn\t\t$7.50\n");
total+=7.5;
break;
case '=':
printf("= Total of $%.2f\n",total);
printf("Please pay the cashier.\n");
done=1;
break;
default:
printf("Improper selection.\n");
} /* end switch */
} /* end while */
return(0);
}