Ryan
2010-02-10 15:39:11 UTC
#include
int main(void)
{
double amount = 0.0;
double numTens = 0;
double numFives = 0;
double numOnes = 0;
double numQuarters = 0;
double numDimes = 0;
double numNickels = 0;
double numPennies = 0;
int change_due = 0.0;
printf("This program computes the change to be given\n");
printf("for a purchase paid for with a $20 bill.\n");
printf("(The purchase must be less than or equal to $20)\n");
printf("Enter your purchase amount:");
scanf("%lg", &amount);
printf("Purchase amount is %lg ", amount);
change_due = (20.00 - amount);
printf("Change due is %d ", change_due);
while( amount >= 10.00 )
{
numTens++;
amount = 10.00;
printf("Tens: %f ", numTens);
}
while( amount >= 5.00 )
{
numFives++;
amount = 5.00;
printf("Fives: %f ", numFives);
}
while( amount >= 1.00 )
{
numOnes++;
amount = 1.00;
printf("Ones: %f ", numOnes);
}
while( amount >= 0.25 )
{
numQuarters++;
amount = 0.25;
printf("Quarters: %f ", numQuarters);
}
while( amount >= 0.10 )
{
numDimes++;
amount = 0.10;
printf("Dimes: %f ", numDimes);
}
while( amount >= 0.05 )
{
numNickels++;
amount = 0.05;
printf("Nickels: %f ", numNickels);
}
while( amount >= 0.01 )
{
numPennies++;
amount = 0.01;
printf("Pennies: %f ", numPennies);
}
while( amount < 0.0 )
{
printf("Please enter an amount greater than zero\n");
printf("and less than or equal to $20");
return 1;
while( amount > 20.0 )
{
printf("Please enter an amount greater than zero\n");
printf("and less than or equal to $20");
return 1;
}
return 0;
}
it is only two error messages away from compiling:
change.c:80: error: expected declaration or statement at end of input
change.c:80: warning: control reaches end of non-void function
PLEASE help soon, how do i fix this?????