PROGRAM CashBills (Input,Output);

(* David Wills
   University of Maryland  CMIS 102
   12 April 1991
   Turbo Pascal 5.5    *)

(* This program prompts the user for an amount of dollars and then
   computes the minimum number of U.S. bills needed to equal that
   amount.  *)

CONST
   Hundred = 100;      (* Values of the bill denominations *)
   Fifty = 50;
   Twenty = 20;
   Ten = 10;
   Five = 5;
   One = 1;

VAR
   Sum : Integer;      (* Dollars amount, user input *)
   Bills : Integer;    (* Number of bills of each denomination *)
   LeftOver : Integer; (* Dollar amount left over after subtracting
                          bills of higher denomination *)

BEGIN
   Writeln('This program calculates the minimum number of bills');
   Writeln('that add up to a user-specified dollar amount.');
   Writeln('Enter a dollar amount:');
   Readln(Sum);

   LeftOver := Sum;

   Bills := LeftOver DIV Hundred;
   LeftOver := LeftOver MOD Hundred;
   Writeln('Number of hundreds = ',Bills);

   Bills := LeftOver DIV Fifty;
   LeftOver := LeftOver MOD Fifty;
   Writeln('Number of fifties = ',Bills);

   Bills := LeftOver DIV Twenty;
   LeftOver := LeftOver MOD Twenty;
   Writeln('Number of twenties = ',Bills);

   Bills := LeftOver DIV Ten;
   LeftOver := LeftOver MOD Ten;
   Writeln('Number of tens = ',Bills);

   Bills := LeftOver DIV Five;
   LeftOver := LeftOver MOD Five;
   Writeln('Number of fives = ',Bills);

   Writeln('Number of ones = ',LeftOver);
END.