WITH
Ada.Text_IO;
WITH Ada.Integer_Text_IO;
WITH Ada.Float_Text_IO;
----------------------------------------------------------------------
-- Program by Matt Tucker, documentation by Shawn Brenneman
-- This program asks a user how many pennies, dimes, or dollars
--
they have,
and then calculates how much money that is.
----------------------------------------------------------------------
PROCEDURE money IS
Type currency IS (pennies,dimes,dollars);
Package currency_IO IS NEW Ada.Text_IO.Enumeration_IO(Enum=>currency);
money_type:currency;
amount:natural;
total:Float;
posit:natural;
BEGIN
-- input statements, get type of money and how many coins from user
Ada.Text_IO.Put(Item=>"Input
the type of money (pennies,dimes,dollars): ");
currency_IO.Get(Item=>money_type);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put(Item=>"How
many ");
currency_IO.Put(Item=>money_type);
Ada.Text_IO.Put(Item=>" do you have?");
Ada.Integer_Text_IO.Get(Item=>amount);
-- get the position of money_type in the currency array
-- conveniently, position of pennies is 0, dimes is 1, dollars is 2
posit:=currency'POS (money_type);
-- use the raise 10 to the position power to calculate the value
total:=Float (amount*(10**posit))/100.00;
-- write the output
Ada.Text_IO.New_Line;
Ada.Text_IO.Put(Item=>"You
have $");
Ada.Float_Text_IO.Put(Item=>total,Fore=>1,Aft=>2,Exp=>0);
END money;