coder newbie here. As far as I understand, this should work. This is the logic of my code...
I get the float input from the user, and keep asking until I receive a positive number.
I change this into a rounded interger.
For each of the coin values, I check the amount is divisible then take this amount away, repetitively.
Then I print the total number of my coins. However I end up with a bunch of errors. Help?
#include <stdio.h> #include <cs50.h> #include <math.h>
int main(void) { float amount;
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
float amount;
do
{
amount = get_float ("Change requested: ");
}
while (amount < 0);
while (amount < 0);
int rounded = roundf(amount*100);
//check amount of quarters
for (rounded >= 0.25; rounded = rounded - 0.25; rounded++)
//check amount of dimes
for (rounded >= 0.10; rounded = rounded - 0.10; rounded++)
//check amount of nickles
for (rounded >= 0.5; rounded = rounded - 0.05; rounded++)
//check amount of pennies
for (rounded >= 0.01; rounded = rounded - 0.01; rounded++)
//print toal number of coins printf("%i\n", rounded);
//print toal number of coins
printf("%i\n", rounded);
}