program ChangeMaker; { This program inputs an item cost and an amount paid } { and calculates change in quarters, dimes, nickels, } { and pennies } { Author: Jerry Mead } { Date: Feb. 1993 } { Modified: Xiannong Meng (changed.pas) } { Sept. 1994 } uses WinCrt; const SalesTaxRate = 0.075; var AmountPaid :integer; { amount entered as paid for the item } Amount2Return :integer; { compute amount of change to return } Dimes2Return :integer; { compute number of dimes to return } ItemCost :integer; { amount entered as cost of the item } Nickels2Return :integer; { compute number of nickels to return } Pennies2Return :integer; { compute number of pennies to return } Quarters2Return :integer; { compute number of quarters to return } TotalCost :integer; { compute item's cost including tax } procedure ReadParameters; { This procedure reads input from user } begin { of ReadParameters } Write ('Specify cost (in cents) >> '); ReadLn (ItemCost); Write ('Specify amount paid (in cents) >> '); ReadLn (AmountPaid); end; { of ReadParameters } procedure Calculate; { This procedure calculates various values } begin { of Calculate } { Calcuate the total cost and the amount to return } TotalCost := round (ItemCost * (1 + SalesTaxRate)); Amount2Return := AmountPaid - TotalCost; WriteLn; { blank line before totals } WriteLn ('Total cost (sales tax incl.): ', TotalCost); WriteLn ('Amount remitted: ', AmountPaid); WriteLn ('Amount to return: ', Amount2Return); { How many quarters in the amount to return? } Quarters2Return := Amount2Return div 25; { How much left? } Amount2Return := Amount2Return mod 25; { Now we try to figure out the dimes } Dimes2Return := Amount2Return div 10; Amount2Return := Amount2Return mod 10; { And the nickles } Nickels2Return := Amount2Return div 5; Amount2Return := Amount2Return mod 5; { Finally, the pennies } Pennies2Return := Amount2Return; end; { of Calculate } procedure PrintResults; { This procedure prints the results } begin { of PrintResults } { Display the results } WriteLn; WriteLn ('Quarters returned: ', Quarters2Return); WriteLn ('Dimes returned: ', Dimes2Return); WriteLn ('Nickels returned: ', Nickels2Return); WriteLn ('Pennies returned: ', Pennies2Return); WriteLn; end; { of PrintResults } begin { ChangeMaker } { Input parameters} ReadParameters; { Calculate the total change, number of quarters, dimes, nickles, and pennies } Calculate; { Display the results } PrintResults; end. { ChangeMaker }