I'm not sure why QUARTER is not being subtracted from Owed_Change and updating it?
As of it it will take user input, convert to an int and round it, for some reason it is ignoring my While loop.
Any help would be much appreciated. Below is the my current code:
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void) {
const int QUARTER = 25;
int CoinCounter = 0;
printf("Please enter change required: ");
float Change = GetFloat();
Change *= 100;
Change = round((int)Change);
int Owed_Change = Change;
while (Owed_Change => QUARTER) { //<---- This is killing me.
Owed_Change -= QUARTER;
}
++CoinCounter;
printf("%i\n" "%i ", Owed_Change, CoinCounter);
}
This is my current revised code:
int main(void) {
const int QUARTER = 25;
int CoinCounter = 0;
printf("Please enter change required: ");
float Change = GetFloat();
Change *= 100;
int a = round(Change);
int Owed_Change = a;
while (Owed_Change >= QUARTER) {
Owed_Change -= QUARTER;
++CoinCounter;
}
printf("%i\n" "%i ", Owed_Change, CoinCounter);
}
Please enter change required: 10.45
20
41 ~/workspace/ $
If my math is correct this would be: 10.45 * 100 = 1045 - 25 = 1020, Why is it printing Owed_Change as 20? I notice it also prints the CoinCounter -1 coin.