Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cs50.h>
- #include <stdio.h>
- #include <math.h>
- int main(void)
- {
- int rf;
- int dollars = 0;
- int quarters = 0;
- int dimes = 0;
- int nickels = 0;
- int pennies = 0;
- int total = 0;
- //printf("please enter the amount of change needed\n"); //printf1
- do
- {
- float f = get_float("Cash owed: ");
- rf = round(f*100);
- if (rf/25>=0)
- {
- quarters = rf/25;
- rf %= 25;
- }
- if (rf/10 >=0)
- {
- dimes = rf/10;
- rf %= 10;
- }
- if (rf/5>=0)
- {
- nickels = rf/5;
- rf %= 5;
- }
- if (rf/1 >=0)
- {
- pennies = rf/1;
- rf %= 1;
- }
- if (rf<0)
- {
- printf("Please enter a positive number:\n");
- }
- //total = dimes + pennies + nickels + quarters;
- }
- while (rf > 0);
- total = dimes + pennies + nickels + quarters;
- printf("%i",total);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement