UNB/ CS/ David Bremner/ teaching/ java/ Coins4.java
import java.text.NumberFormat;

public class Coins4
{  public static void main(String[] args)
   {  final double PENNY_VALUE = 0.01;
      final double NICKEL_VALUE = 0.05;
      final double DIME_VALUE = 0.1;
      final double QUARTER_VALUE = 0.25;
         
      ConsoleReader console = new ConsoleReader(System.in);
      
      System.out.println("How many pennies do you have?");
      int pennies = console.readInt();

      System.out.println("How many nickels do you have?");
      int nickels = console.readInt();

      System.out.println("How many dimes do you have?");
      int dimes = console.readInt();

      System.out.println("How many quarters do you have?");
      int quarters = console.readInt();

      double total = pennies * PENNY_VALUE 
         + nickels * NICKEL_VALUE 
         + dimes * DIME_VALUE 
         + quarters * QUARTER_VALUE;
            // total value of the coins

      NumberFormat formatter 
         = NumberFormat.getCurrencyInstance();
         
      System.out.println("Total value = " 
         + formatter.format(total));
   }
}