CMPS 350 - Lab 06 "Introduction to Ada"

resources:
ada README
ada 95 ref manual
ada example code
Ada was developed as a language for real-time embedded systems (primarily avionics). In this domain reliability and concurrency are important. Ada is still the number one software in avionics. You might be interested in reading about The Return of Ada. This article on Ada vs C++ introduces Ada in terms of things you already know. For file I/O, read this tutorial on Ada I/O. (The other Ada tutorials are also very good.)

Everything you need to know for this lab is in testada.adb.

You will use lab06.in for input.

Your job is to write an Ada program that performs array multiplication. Use a program of at least two procedures (any way you want to do it). If you manage your scoping, you don't need to pass parameters to your procedure. You can pass parameters if you want - testada.adb demonstrates how to do that.

Declare two arrays of size 3 by 5 of integers. Load the arrays from an external text file of random integers. Design your array ADT to enforce all range constraints (index ranges and value ranges). Make both ranges large enough to run the program without raising an exception. So if the value range of your input numbers is 1..300, then the value range of the integers in your result array must include larger values since you do multiplication. (If you use type INTEGER then you are OK - you should try a sub-range to get a feel for what you can do in Ada).

Assume filename 'lab06.in' and this format (15 integers per line):

 1  3 8 4 10 2  4  38 43 4 8 12 32 16 6
 23 8 9 9 18 41 11 21 12 2 1 6  33 11 22

Multiply the two arrays and store the values in a third array. Perform array multiplication as:
 a(1,1)*b(1,1)=c(1,1)
 a(1,2)*b(1,2)=c(1,2)
 a(1,3)*b(1,3)=c(1,3)
      ...
 a(3,5)*b(3,5)=c(3,5)

Finally, write the contents of the output array to an output file 'lab06.out'. For formatting, see Ada I/O for Integer Types.

HOW YOUR LAB WILL BE GRADED

The files for this lab must reside in this directory:
 
   /home/stu/{username}/cs350/lab06/lab06.adb
   /home/stu/{username}/cs350/lab06/lab06.in
   /home/stu/{username}/cs350/lab06/Makefile

Sample run:

   $ make
   gnatbind -x lab06.ali
   gnatlink lab06.ali
   $ ./lab06
   $ cat lab06.out
   23   24   72   36  180   82   44  798  516    8    8   72 1056  176  132