-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbalancing_checkbook.c
More file actions
39 lines (34 loc) · 927 Bytes
/
balancing_checkbook.c
File metadata and controls
39 lines (34 loc) · 927 Bytes
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
# include <stdio.h>
int main(void)
{
int cmd;
float balance = 0.0f, credit, debit;
printf("*** ACME checkbook-balancing program ***\n");
printf("Commands: 0=clear, 1=credit, 2=debit, 3=balance, 4=exit\n\n");
for (;;)
{
printf("Enter command: ");
scanf("%d", &cmd);
switch (cmd)
{
case 1:
printf("Enter amount of credit: ");
scanf("%f", &credit);
balance += credit;
break;
case 2:
printf("Enter amount of debit: ");
scanf("%f", &debit);
balance -= debit;
break;
case 3:
printf("Current balance is: $%.2f\n", balance);
break;
case 4:
return 0;
default:
printf("Commands: 0=clear, 1=credit, 2=debit, 3=balance 4=exit\n\n");
break;
}
}
}