catalyst19002800
asked on
Bills
User enters dollar amount as float
output should be the highest number of bills and coins (TWENTIES, TENS, FIVES, ONES, quarters, dimes, nickels, pennies). Any help is appreciated.
#include <stdio.h>
void main()
{
unsigned TWENTIES, TENS, FIVES, ONES, quarters, dimes, nickels, pennies;
float amount_user;
printf("Enter Dollar amount between $0.00 and $100.00:");
scanf("%d", &amount_user);
amount_user=amount_user*10 0;
printf("%d, amount_user\n");
while (amount_user !=0)
{
if(amount_user>=2000)
{
amount_user=amount_user/20 00;
}
else if(amount_user>=1000)
{
amount_user-=1000;
TENS++;
}
else if(amount_user>=500)
{
amount_user-=500;
FIVES++;
}
else if(amount_user>=100)
{
amount_user-=100;
ONES++;
}
else if(amount_user>=25)
{
amount_user-=25;
quarters++;
}
else if(amount_user>=10)
{
amount_user-=10;
dimes++;
}
else if(amount_user>=05)
{
amount_user-=5;
nickels++;
}
else if(amount_user>=1)
{
amount_user-=1;
pennies++;
}
else
{
break;
}
}
printf("There are %d TWENTIES\n", TWENTIES);
printf("There are %d TENS\n", TENS);
printf("There are %d FIVES\n", FIVES);
printf("There are %d ONES\n", ONES);
printf("There are %d quarters\n", quarters);
printf("There are %d dimes\n", dimes);
printf("There are %d nickels\n", nickels);
printf("There are %d pennies\n", pennies);
}
output should be the highest number of bills and coins (TWENTIES, TENS, FIVES, ONES, quarters, dimes, nickels, pennies). Any help is appreciated.
#include <stdio.h>
void main()
{
unsigned TWENTIES, TENS, FIVES, ONES, quarters, dimes, nickels, pennies;
float amount_user;
printf("Enter Dollar amount between $0.00 and $100.00:");
scanf("%d", &amount_user);
amount_user=amount_user*10
printf("%d, amount_user\n");
while (amount_user !=0)
{
if(amount_user>=2000)
{
amount_user=amount_user/20
}
else if(amount_user>=1000)
{
amount_user-=1000;
TENS++;
}
else if(amount_user>=500)
{
amount_user-=500;
FIVES++;
}
else if(amount_user>=100)
{
amount_user-=100;
ONES++;
}
else if(amount_user>=25)
{
amount_user-=25;
quarters++;
}
else if(amount_user>=10)
{
amount_user-=10;
dimes++;
}
else if(amount_user>=05)
{
amount_user-=5;
nickels++;
}
else if(amount_user>=1)
{
amount_user-=1;
pennies++;
}
else
{
break;
}
}
printf("There are %d TWENTIES\n", TWENTIES);
printf("There are %d TENS\n", TENS);
printf("There are %d FIVES\n", FIVES);
printf("There are %d ONES\n", ONES);
printf("There are %d quarters\n", quarters);
printf("There are %d dimes\n", dimes);
printf("There are %d nickels\n", nickels);
printf("There are %d pennies\n", pennies);
}
catalyst19002800 what you mean by "the highest number of bills and coins".
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your objective can be achieved in about 10 lines of C code, using a simple "for' loop
for more details , get back to me.
-rsjetty
for more details , get back to me.
-rsjetty
Your objective can be achieved in about 10 lines of C code, using a simple "for' loop
for more details , get back to me.
-rsjetty
for more details , get back to me.
-rsjetty
ASKER
This was mostly correct but some of the answers were wrong and that was fixed. One too little peenies. Anyway, I played around with the last While(---) and got it fixed. Thanks for your help.
Would you mind telling what was wrong, and what has been your fix?