标签:ada
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure Main is type Coin is ( Penny, Nickel, Dime, Quarter, Half_Dollar, Dollar ); Coin_Value : constant array ( Penny .. Dollar ) of Integer := ( Penny => 1, Nickel => 5, Dime => 10, Quarter => 25, Half_Dollar => 50, Dollar => 100 ); total_change, coin_count, num_dollars, num_cents : Integer; begin total_change := 0; Put_Line( "Enter the number of each coin : " ); for next_coin in Penny .. Dollar loop Get( coin_count ); total_change := total_change + coin_count * Coin_Value( next_coin ); end loop; num_dollars := total_change / 100; num_cents := total_change rem 100; Put( "Total change is $" ); Put( num_dollars ); if num_cents < 10 then Put( ".0" ); Put( num_cents ); else Put( "." ); Put( num_cents ); end if; end Main;
标签:ada
原文地址:http://blog.csdn.net/pandora_madara/article/details/38902371