anonymous / gist:5149538
Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Penny calculation not working.

View gist:5149538
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>
#include <cs50.h>
#include <math.h>
 
#define QUARTER 25 //quarter converted to 25 cents
#define DIME 10 //dime converted to 10 cents
#define NICKLE 5 //nickle converted to 5 cents
#define PENNY 1 //penny converted to 1 cent
 
int main()
{
 
printf("Please deposit your coins?\n");
float coin_amount = GetFloat();
int amount_converted = coin_amount * 100;
int quarters = amount_converted / QUARTER;
while ( amount_converted >= QUARTER )
{
amount_converted -= 25;
}
int dimes = amount_converted / DIME;
while ( amount_converted >= DIME )
{
amount_converted -= 10;
}
int nickles = amount_converted / NICKLE;
while ( amount_converted >= NICKLE )
{
amount_converted -= 5;
}
int pennies = amount_converted / PENNY;
printf("Quarters\t%d\n", quarters);
printf("Dimes\t\t%d\n", dimes);
printf("Nickles\t\t%d\n", nickles);
printf("Pennies\t\t%d\n", pennies);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.