Starting from:

$25

COMP3220-Ada Assignment Solved

For this programming assignment, you will be writing an ada program that primarily works with binary arrays. A binary array is simply an array that is of length 16 that can ONLY hold 1’s and 0’s. You will need to implement the following procedures and functions (recall that procedures ONLY work with parameters and don’t return anything, while functions return data), whose prototypes have been provided to you in the assgn.ads package (this file is kind of like a header file in c, you will need to define these protocols in assgn.adb). 

1)    Procedure Init_Array. Accepts a two-way parameter (in-out mode) that is a BINARY_ARRAY and fills it with an initial set of random values. Keep in mind as you generate this binary array that generating a binary value too large could result in an overflow when attempting to add two binary arrays together. 

2)    Procedure Print_Bin_Array. This procedure accepts a BINARY_ARRAY (in-mode only) and simply prints it to the console. 

3)    Procedure  Reverse_Bin_Arr. This procedure accepts a BINARY_ARRAY (in-out mode) parameter and simply reverses that BINARY_ARRAY.

4)    Function Int_To_Bin. This function accepts an INTEGER value (in-mode only) and returns the equivalent BINARY_ARRAY

5)    Function Bin_To_Int. This function accepts a BINARY_ARRAY value (in-mode only) and returns the equivalent INTEGER. 

Overloaded functions: When doing addition or subtraction for the overloaded operators below, you MUST perform BINARY addition or subtraction (adding or subtracting 1’s and 0’s one position at a time, and carrying, if necessary. Do NOT simply convert to integer values and add or subtract integers. 

6)    Overloaded “+” operator that accepts an INTEGER type and a BINARY_ARRAY type (in-mode only), adds them together and returns a BINARY_ARRAY that is the result. 

7)    A second Overloaded “+” operator that accepts two BINARY_ARRAY types (in-mode only), adds them together and returns the result as a BINARY_ARRAY

Two Overloaded “–“ operators that behave like #6 and #7 above

More products