import java.util.Scanner;
public class PP_2_11a
{
//---------------------------------------------------------------------
// Reads amount of money and determines what bills and coins are needed
//---------------------------------------------------------------------
public static void main (String[]args)
{
double total_amount;
Scanner scan = new Scanner (System.in);
boolean more = true;
while (more)
{
System.out.println ("Enter amount of money.");
total_amount = scan.nextDouble();
int tens = (int)total_amount/10;
total_amount = total_amount%10;
int fives = (int)total_amount/5;
total_amount = total_amount%5;
int ones = (int)total_amount/1;
total_amount = total_amount%1;
int quarters = (int)(total_amount/.25);
total_amount = (total_amount%.25);
int dimes = (int)(total_amount/.10);
total_amount = (total_amount%.10);
int nickels = (int)(total_amount/.05);
total_amount = (total_amount%.05);
int pennies = (int)(total_amount%.01);
System.out.println (tens + " ten dollar bills");
System.out.println (fives + " five dollar bills");
System.out.println (ones + " one dollar bills");
System.out.println (quarters + " quarters");
System.out.println (dimes + " dimes");
System.out.println (nickels + " nickels");
System.out.println (pennies + " pennies");
System.out.print ("Enter 1 to continue, 0 to quit > ");
more = (1 == scan.nextInt());
}
}
}
it does not calculate properly when I input the amount 68.97
please help
thank you!