Ada Programming Assignment Solution

$30.00 $24.00


You'll get a: . zip file solution : immediately, after Payment


The experienced C programmer will probably be a bit frustrated with the attention to details required by the Ada compiler. You will not have your favorite “tricks” available to fool the compiler into doing something out of the ordinary. The Ada compiler cannot be fooled. –

For this programming assignment, you will be writing an ada program that will do the following:

  1. Create a binary array of 1’s and 0’s that is of length 16.
    1. Your binary array should be a user-defined type called BINARY_ARRAY that can ONLY store numbers that are of type BINARY_NUMBER
    2. BINARY_NUMBER is another user-defined type that is a numeric value of either 0 or 1.
    3. To populate your array, you must generate 16 random 0’s or 1’s using a for loop
  2. Your program must have the following FUNCTIONS:
    1. Bin_To_Int accepts one BINARY_ARRAY as a parameter and returns the integer equivalent of that binary value. You must calculate this using a loop. DO NOT use a function built-in to ada to do this.
    2. Int_To_Bin accepts an integer value (you may want to limit the size as we only have 16 “bits” to store it in) and returns a BINARY_ARRAY set to the binary equivalent of that integer value. The binary array should be in the correct order (least significant bit at the far right).
    3. Overloaded “+”
      1. One version of this should add two BINARY_ARRAYs and return a BINARY_ARRAY as a result. Don’t worry about overflows.
      2. The other version of this should accept a BINARY_ARRAY and an integer and return a BINARY_ARRAY as a result.
    4. Overloaded “-“ (same as above except subtract the second from the first parameter)
  3. Your program must have the following procedures:
    1. Reverse_Bin_Arr accepts a BINARY_ARRAY and simply reverses it.
    2. Print_Bin_Arr accepts a BINARY_ARRAY and prints it to the console.
  4. Your “main” should do the following:
    1. #1 described above
    2. Call your Bin_To_Int function from 2a and display the result on the console
    3. Call your Int_To_Bin function and save the return value into a second BINARY_ARRAY.
    4. Call your Print_Bin_Arr procedure from 3b to display the newly created binary array.
    5. Use your overloaded + function on arrays 1 and 2, and save the return value into a third BINARY_ARRAY. Print this as well using your print procedure
    6. Use your overloaded – function on arrays 1 and 2, and save the return value into a fourth BINARY_ARRAY. Print this as well.
    7. Finally, reverse the fourth BINARY_ARRAY using your Reverse_Bin_Arr procedure from 3a, and print the result.

TIP: You will need to create more variables than the one single array I mentioned in the instructions above.

Helpful Links:

Download here. You want GNAT ada 2016:

Old but very useful (careful with the chapter on packages. Newer versions of ada require you to write them in two separate files. The specification belongs in .ads, and the implementation belongs in .adb):

Other Useful Links: