UNB/ CS/ David Bremner/ teaching/ java/ Coins3.java
public class Coins3
{  public static void main(String[] args)
   {  final int PENNY_VALUE = 1;
      final int NICKEL_VALUE = 5;
      final int DIME_VALUE = 10;
      final int QUARTER_VALUE = 25;
      final int DOLLAR_VALUE = 100;
         
      int pennies = 8; // the purse contains 8 pennies,
      int nickels = 0; // no nickels
      int dimes = 4; // four dimes
      int quarters = 3; // and three quarters
      
      // compute total value in pennies

      int total = pennies * PENNY_VALUE 
         + nickels * NICKEL_VALUE
         + dimes * DIME_VALUE 
         + quarters * QUARTER_VALUE;
         
      // use integer division to convert to dollars, cents

      int dollar = total / DOLLAR_VALUE;
      int cents = total % DOLLAR_VALUE;
      
      System.out.print("Total value = ");
      System.out.print(dollar);
      System.out.print(" dollar and ");
      System.out.print(cents);
      System.out.println(" cents");
   }
}