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 } { 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 cost including tax } begin { ChangeMaker } { Input parameters} Write ('Specify cost (in cents) >> '); ReadLn (ItemCost); Write ('Specify amount paid (in cents) >> '); ReadLn (AmountPaid); { 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; { Display the results } WriteLn; WriteLn ('Quarters returned: ', Quarters2Return); WriteLn ('Dimes returned: ', Dimes2Return); WriteLn ('Nickels returned: ', Nickels2Return); WriteLn ('Pennies returned: ', Pennies2Return); WriteLn; end. { ChangeMaker }