mirror of https://github.com/me50/kukemuna.git
This commit is contained in:
commit
0a520866d9
|
|
@ -0,0 +1,50 @@
|
||||||
|
#include <cs50.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int get_quarters(int cents);
|
||||||
|
int get_dimes(int cents);
|
||||||
|
int get_nickels(int cents);
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int cents, quarters, dimes, nickels, pennies;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
cents = get_int("Change owed: ");
|
||||||
|
}
|
||||||
|
while (cents < 0);
|
||||||
|
|
||||||
|
quarters = get_quarters(cents);
|
||||||
|
cents = cents % 25;
|
||||||
|
|
||||||
|
dimes = get_dimes(cents);
|
||||||
|
cents = cents % 10;
|
||||||
|
|
||||||
|
nickels = get_nickels(cents);
|
||||||
|
|
||||||
|
pennies = cents % 5;
|
||||||
|
|
||||||
|
cents = quarters + dimes + nickels + pennies;
|
||||||
|
printf("%i\n", cents);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_quarters(int cents)
|
||||||
|
{
|
||||||
|
cents /= 25;
|
||||||
|
return cents;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_dimes(int cents)
|
||||||
|
{
|
||||||
|
cents /= 10;
|
||||||
|
return cents;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_nickels(int cents)
|
||||||
|
{
|
||||||
|
cents /= 5;
|
||||||
|
return cents;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue