019.一个略微有用的程序,摄氏度与华氏度之间的转换

本文介绍了一个程序,用于生成从-20°C到120°C的摄氏度与华氏度温度对照表,特别标注了水的冰点和沸点。程序使用Ada语言编写,通过循环计算每个10°C间隔的对应华氏度。
-- Centigrade to Farenheit temperature table
--
--  This program generates a list of Centigrade and Farenheit
--    temperatures with a note at the freezing point of water
--    and another note at the boiling point of water.

with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;

procedure TempConv is

   Centigrade, Farenheit : INTEGER;

begin
   Put("Centigrade to Farenheit temperature table");
   New_Line(2);
   for Count in INTEGER range -2..12 loop
      Centigrade := 10 * Count;
      Farenheit := 32 + Centigrade * 9 / 5;
      Put("C =");
      Put(Centigrade, 5);
      Put("    F =");
      Put(Farenheit, 5);
      if Centigrade = 0 then
         Put("  Freezing point of water");
      end if;
      if Centigrade = 100 then
         Put("  Boiling point of water");
      end if;
      New_Line;
   end loop;
end TempConv;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值