CSE 1001: Lab Assignment #1

Part 1

Write the shortest possible Ada program. Can the program be written in one line? What is the importance of style?

Part 2

Complete the following Ada program and change the string constants. Change the values so the information correctly reflects your name, student number and e-mail address.

with Ada.Text_IO, Ada.Characters.Latin_1;
use Ada, Ada.Characters;

procedure Hello is
   Tab          : Character renames Latin_1.HT;
   Name_1       : constant String := "Stansifer, Ryan";
   Student_Id_1 : constant String := "XXX-YY-ZZZZ";
   E_Mail_1     : constant String := "ryan@cs.fit.edu";
begin
   -- print name, student number and e-mail address
   -- separated by horizontal tabs.
end Hello;
Cut and paste the program from this WWW page and into the Ada IDE.

Part 3

Repair the following program so that it compiles.
    __ This program is all wrong
    procedure Bad;
       Total Hours : constant Integer := 1_2;
       S : Integer
    begen
       S : = 3;
    end Bad.

Part 4

Write an Ada Program that converts the temperature 21 degree centigrade to its Fahrenheit equivalent. The conversion formula is
Fahrenheit = 9/5 Centigrade + 32
Make the temperature 21 a constant in your programs. Print the equivalent temperature in Fahrenheit to standard input.

Notice that you cannot translate this directly into Ada:

  1. Multiplication of integers is denoted by * in Ada.
  2. Division of integers loses information (the remainder)

Ryan Stansifer <ryan@cs.fit.edu>
Last modified: Tue Jan 26 15:19:11 EST 1999