The programming language for this is ada.
So I have a lab I need to do for my CS class, and I got it basically done. The only problem is, I can enter the cost, and the amount tendered. But after that it doesn't return any of the values.
What is supposed to happen is that it is supposed to take the change and tell you how many dollars, quarters, dimes, nickels and pennies that it gives you.
Here is what I have so far:
with ada.text_io;
with ada.integer_text_io;
use ada.text_io;
use ada.integer_text_io;
procedure Change is
Dot : Character;
Price_Dollars, Price_Pennies, End_Program : Integer;
Tender_Dollars, Tender_Pennies : Integer;
Change_Dollars, Change_Quarters, Change_Dimes, Change_Nickels, Change_Pennies : Integer;
begin
dot := '.';
Put ("Enter the price in Dollars and Cents: $ ");
Get (Price_Dollars);
Get (Dot);
Get (Price_Pennies);
Put ("Enter the amount tendered in Dollars and Cents: $ ");
Get (Tender_Dollars);
Get (Dot);
Get (Tender_Pennies);
New_line;
Price_Pennies := 100 * Price_Dollars + Price_Pennies;
Tender_Dollars := 100 * Tender_Dollars + Tender_Pennies;
--If (Price_Pennies > Tender_Pennies) then
--Put ("You do not have enough money to do this transaction, please come back with more money and try again.");
--else
Change_Pennies := Tender_Pennies - Price_Pennies;
Change_Dollars := Change_Pennies / 100;
Change_Pennies := Change_Pennies rem 100;
Change_Quarters := Change_Pennies / 25;
Change_Pennies := Change_Pennies rem 25;
Change_Dimes := Change_Pennies / 10;
Change_Pennies := Change_Pennies rem 10;
Change_Nickels := Change_Pennies / 5;
Change_Pennies := Change_Pennies rem 5;
if (Change_Dollars > 0) then
If (Change_Dollars > 1) then
Put (Change_Dollars);
Put (" Dollars");
else
Put (Change_Dollars);
Put (" Dollar");
end if;
end if;
if (Change_Quarters > 0) then
if (Change_Quarters > 1) then
Put (Change_Quarters);
Put (" Quarters");
else
Put (Change_Quarters);
Put (" Quarter");
end if;
end if;
if (Change_Dimes > 0) then
if (Change_Dimes > 1) then
Put (Change_Dimes);
Put (" Dimes");
else
Put (Change_Dimes);
Put (" Dime");
end if;
end if;
if (Change_Nickels > 0) then
if (Change_Nickels > 1) then
Put (Change_Nickels);
Put (" Nickels");
else
Put (Change_Nickels);
Put (" Nickel");
end if;
end if;
if (Change_Pennies > 0) then
if (Change_Pennies > 1) then
Put (Change_Pennies);
Put (" Pennies");
else
Put (Change_Pennies);
Put (" Penny");
end if;
end if;
get (End_Program);
--end if;
end Change;
Please let me know what my problem is, Thanks.