      1  import java.util.Scanner;

      2

      3  /**

      4     This program simulates a stamp machine that receives dollar bills and dispenses

      5     first class and penny stamps.

      6  */

      7  public class StampMachine

      8  {

      9     public static void main(String[] args)

     10     {

     11        Scanner in = new Scanner(System.in);

     12

     13        final int FIRST_CLASS_STAMP_PRICE = 44; // Price in pennies

     14

     15        System.out.print("Enter number of dollars: ");

     16        int dollars = in.nextInt();

     17

     18        // Compute and print the number of stamps to dispense

     19

     20        int firstClassStamps = 100 * dollars / FIRST_CLASS_STAMP_PRICE;

     21        int change = 100 * dollars - firstClassStamps * FIRST_CLASS_STAMP_PRICE;

     22        System.out.printf("First class stamps: %6d\n", firstClassStamps);

     23        System.out.printf("Penny stamps:       %6d\n", change);

     24     }

     25  }