Create a Change application that prompts the user for an amount less than $1.00 and then displays the minimum number of coins necessary to make the change. The change can be made up of quarters, dimes, nickels, and pennies. The application output should look similar to:
Enter the change in cents: 212
The minimum number of coins is:
Quarters: 8
Dimes: 1
Nickels 0
Pennies: 2
Must be coded in Java please
//CoinExchange.java import java.util.Scanner; public class CoinExchange { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the change in cents: "); int n = scan.nextInt(); System.out.println("Quarters: "+(n/25)); n = n%25; System.out.println("Dimes: "+(n/10)); n = n%10; System.out.println("Nickels: "+(n/5)); n = n%5; System.out.println("Pennies: "+(n)); } }
Get Answers For Free
Most questions answered within 1 hours.