-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoinprocessor.c
More file actions
38 lines (37 loc) · 1.36 KB
/
coinprocessor.c
File metadata and controls
38 lines (37 loc) · 1.36 KB
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
//This program takes as input coins like at a supermarket and drafts it into a bill
//purpose: turn coins into a bill
#include <stdio.h>
int main(void){
//declare variables
// we need char so we know the name of the person, pennies, nickles, dimes, quarters because those are change
char first, middle, last;
int pennies, nickles;
int dimes, quarters;
int dollars;
int change;
int total_dollars;
int total_cents;
//get and display the name of the person
printf("Give your first name, middle, and last: ");
scanf("%c%c%c", &first, &middle, &last);
printf("\n%c%c%c, please enter your coin information: ", first, middle, last);
//get the count
printf("Number of coins: ");
scanf("%d", &dollars);
printf("Number of quarters: ");
scanf("%d", &quarters);
printf("The number of dimes: ");
scanf("%d", &dimes);
printf("Number of nickles: ");
scanf("%d", &nickles);
printf("The number of pennies: ");
scanf("%d", &pennies);
//compute the total values
total_cents = 100 * dollars + 25 * quarters + 10 * dimes + 5 * nickles + pennies;
//find the total dollars
total_dollars= total_cents/100;
//change
change= total_cents % 100;
//display the credit slip
printf("\n\n%c%c%c Coin Credit \nDollars: %d\nChange: %d cents\n", first, middle, last, total_dollars, change);
}