ITEC 320: Homework 2


Due Date: 11:59:59 p.m. Wednesday 1/29/2020

Submit Command: submit itec320-01 fix_errors.adb


Last modified:
Updates:

  1. No updates at this time.


This homework will help you learn how to fix compilation errors. You are to do the following:

  1. Fix all of the compilation errors in the program below.
  2. After program compiles, verify that it gives the same result as the sample run below

Your program should produce the following output:

Sample Run:

rucs@/home/nokie> ./h2
         10
         55
5.5

Program to Fix: Fix the errors in the program below:

-- File: fix_errors.adb
-- Name: 
-- Date: 

-- This program is supposed to print the following:
--    n,
--    the sum of the values from 1 to n
--    the average of those values
--
-- The program contains about 17 compilation errors.  Fix those errors.
-- After fixing the syntax errors, compare it's output with the sample run,
--   and fix any additional errors.
-- You should correct the errors in order as the compiler identifies them.
--
-- Sample run:
--          10
--          55
--
-- 5.5

with ada.text_io; use ada.text_io; 
with ada.integer_text_io; use ada.integer_text_i; 
with ada.float_text_io; use ada.float_text_io; 
 
procedre fix_errors  is 
   sum:: Integr;
   avg:= Float
   n: constnt Integer = 10;
begin
   sm := 0;
   for i in 1 .. n
      sum := sum | i;
   end;

   avg := sum / n;

   new_line;
   put_line(n);

   new_line();
   put_line(sum);

   println();
   put_line();

   put(1, 1, avg);
   new_lne;
end fix_errors;

Creating your adb file: Your data file can be created with any editor, but don't use an editor (such as wordpad) that stores characters using 16 rather than 8 bits. Also don't use an editor that creates an RTF (ie rich text) file. If you use AdaGIDE or GPS, then this will not be a problem.

Compilers: The Ada compiler gnat and the Ada IDE's AdaGide and GPS are installed on department machines. AdaGide is easier to use, but GPS has more features. You can also use the gnat compiler using the command line with a local shell or by using a terminal window (eg putty) to login to a local Linux machine called rucs. To use putty from off campus you must first be running a VPN session.

You may also want to install these tools on your personal machine. The site www.adacore.com/community has a installers for the GNAT compiler (which also installs gps) for a variety of platforms. AdaGIDE is available from adagide.martincarlisle.com. Make sure that you install gnat before installing adagide. An Eclipse plugin is available from the Adacore site. Visual Studio Code has partial support for Ada. See configuration instructions for Ada here Another source for gnat is getadanow.com (but I recommend downloading from AdaCore).

More instructions on compilers is available here and here.

Submission: Use the submit command to turn your program in for grading. You do not need to submit any data files. You may submit as many times as you like, but only the last submission is kept because submit wipes out any earlier submissions of the same name. Since only the last submission is kept, if the last one is late, then your assignment is late and will thus receive a late penalty. Also remember that you must be on rucs for submit to work. To submit your work for grading do the following:

   submit itec320-01 fix_errors.adb 
Notice that you are to submit ONLY the adb source file.

Late Penalty: Late programs not accepted (unless you have very extenuating circumstances).