ChangeCounter - System.out.print ("Enter the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // ChangeCounter.java Author: Lewis and Loftus // // Solution to Programming Project 2.12 //******************************************************************** / import java.util.Scanner; import java.text.NumberFormat; i public class ChangeCounter { //----------------------------------------------------------------- // Computes the total value of a collection of coins. //----------------------------------------------------------------- public static void main (String[] args) { int quarters, dimes, nickels, pennies; double total; Scanner sc = new Scanner(System.in);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.print ("Enter the number of quarters: "); quarters = Integer.parseInt(sc.nextLine()); System.out.print ("Enter the number of dimes: "); dimes = Integer.parseInt(sc.nextLine()); System.out.print ("Enter the number of nickels: "); nickels = Integer.parseInt(sc.nextLine()); System.out.print ("Enter the number of pennies: "); pennies = Integer.parseInt(sc.nextLine()); total = quarters * 25 + dimes * 10 + nickels * 5 + pennies; total = total / 100; NumberFormat fmt = NumberFormat.getCurrencyInstance(); System.out.println ("Total value: " + fmt.format(total)); } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Ask a homework question - tutors are online