Ask Question
27 April, 12:34

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.

+2
Answers (1)
  1. 27 April, 13:05
    0
    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
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “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 ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers