package decisionsolutions; import java.util.Scanner; public class ComputeChange { public static void main(String[] args) { // Create a Scanner Scanner input = new Scanner(System.in); // Receive the amount System.out.print( "Enter an amount in double, for example 11.56: "); double amount = input.nextDouble(); int remainingAmount = (int)(amount * 100); // Find the number of one dollars int numberOfOneDollars = remainingAmount / 100; remainingAmount = remainingAmount % 100; // Find the number of quarters in the remaining amount int numberOfQuarters = remainingAmount / 25; remainingAmount = remainingAmount % 25; // Find the number of dimes in the remaining amount int numberOfDimes = remainingAmount / 10; remainingAmount = remainingAmount % 10; // Find the number of nickels in the remaining amount int numberOfNickels = remainingAmount / 5; remainingAmount = remainingAmount % 5; // Find the number of pennies in the remaining amount int numberOfPennies = remainingAmount; // Display results String output = "Your amount " + amount + " consists of \n"; if(numberOfOneDollars > 1) output = output + "\t" + numberOfOneDollars + " dollars\n"; else if(numberOfOneDollars == 1) output = output + "\t1 dollar\n"; if(numberOfQuarters > 1) output = output + "\t" + numberOfQuarters + " quarters\n"; else if(numberOfQuarters == 1) output = output + "\t1 quarter\n"; if(numberOfDimes > 1) output = output + "\t" + numberOfDimes + " dimes\n"; else if(numberOfDimes == 1) output = output + "\t1 dime\n"; if(numberOfNickels > 1) output = output + "\t" + numberOfNickels + " nickels\n"; else if(numberOfNickels == 1) output = output + "\t1 nickel\n"; if(numberOfPennies > 1) output = output + "\t" + numberOfPennies + " pennies\n"; else if(numberOfPennies == 1) output = output + "\t1 penny\n"; System.out.println(output); } }