Assignment 4 for CSCI 431: Ada

The gnat compiler for Ada has been installed on Burnsville. Here is a brief set of instructions for compiling a simple procedure or function (something that is not part of a package and does not use multiple tasks).

Programming Assignment

  1. Part 1: Modifying a program


  2. Part 2: Writing a program
    To complete this assignment, you will need to use IF-THEN-ELSE statements and FLOATing point arithmetic.
    1. The program Description:
      Write an Ada program called "Triangle" which reads the lengths of 3 sides of a triangle and determines if the triangle is "obtuse."
      Definition: A triangle having sides A, B, and C, where C is a side of maximal length, is "obtuse" if A*A + B*B < C*C

    2. Input to the Program:
      The user of your program will enter three FLOAT values A, B and C, representing the lengths of the sides of a triangle, where the last length C will be no smaller than A and B. You may assume the input is typed correctly.
      The program will then determine whether the triangle is obtuse or not, and will print an appropriate message.

    3. Sample Output:
      Your program should issue a prompt to the user, asking for the three sides of the triangle. Below are some sample runs of the program (user responses appear in italix)
      (Run 1)
      Enter the sides of a triangle (put the longest length last):
        5.0  4.0   6.0 
      The triangle is not obtuse.
      
      (Run 2)
      Enter the sides of a triangle (put the longest length last):
        3.0  4.0   6.0 
      The triangle is obtuse.
      
    4. Ada Packages that you will need to use:
      You will need the package "Text_IO" in order for your program to use GET, PUT and NEWLINE for text data. You will also need to input and output floating point numbers which will require instantiating a generic child package of Text_IO with the FLOAT type as follows:
      
      
            with Text_IO; use Text_IO;
            procedure Triangle is
                package Flt_IO is new Float_IO(INTEGER); use Flt_IO;
                ...
      
            begin 
      
    5. Handing in your program:
      Hand in your program by submitting it to your ftp directory for this class.

      More Information on Ada

      Here is a little bit more information about the Text_IO package. There are also several good Ada web sites, I've listed a few of them here.