Beginner here, and I feel like I am so close to solving this problem but for some reason whenever I run my code, it just keeps asking me over and over again to enter how much change I am owed and doesn't print the amount of coins
The Problem:
Write, in a file called cash.c in ~/workspace/pset1/cash/, a program that first asks the user how much change is owed and then spits out the minimum number of coins with which said change can be made
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
float x;
int coin_amount = 0;
do
{
x = get_float("how much change is owed: $");
}
while (x < 0);
while (x >= .25)
{
coin_amount += 1;
x = x - .25;
}
while (x >= .10 && x < .25)
{
coin_amount += 1;
x = x - .10;
}
while (x >= .05 && x < .10)
{
coin_amount += 1;
x = x - .05;
}
while (x >= .01 && x < .05)
{
coin_amount += 1;
x = x - .01;
}
while (x < .01)
{
coin_amount = coin_amount;
}
printf("I have %i coins to give you in change\n", coin_amount);
}
Any idea's in what I am doing wrong? Thank you :)