Write an application that determines the value of the coins in a jar and prints the total in dollars and cents. Read integer values that represent the number of quarters, dimes, nickels, and pennies. Use a currency formatter to print the output.

Respuesta :

Answer: Result:Enter the number of quarters in the jar: 4

Enter the number of dimes in the jar: 5

Enter the number of nickels in the jar: 2

Enter the number of pennies in the jar: 5

Total value is 1 dollars and 65 cents

Explanation: import java.util.Scanner;public class Coins { public static void main(String[]args) { int quarters, dimes, nickels, pennies; int total;Scanner scan = new Scanner (System.in);System.out.print("Enter the number of quarters in the jar: "); quarters = scan.nextInt();System.out.print("Enter the number of dimes in the jar: ");dimes = scan.nextInt(); System.out.print("Enter the number of nickels in the jar: ");nickels= scan.nextInt(); System.out.print("Enter the number of pennies in the jar: ");pennies = scan.nextInt(); int total_cents = 25*quarters + dimes*10 + nickels*5 + pennies;total =total_cents/100;total_cents = total_cents %100;System.out.println("Total value is " + total + " dollars and " + total_cents + " cents ");}}

Result:Enter the number of quarters in the jar: 4

Enter the number of dimes in the jar: 5

Enter the number of nickels in the jar: 2

Enter the number of pennies in the jar: 5

Total value is 1 dollars and 65 cents

Answer:

5

2

and 5

Explanation:

just do it youll see