ITEC 320: Homework 1


Due Date: 11:59:59 p.m. Tuesday 1/23/2018

Submit Command: submit itec320-01 homework_one.adb homework_one.o homework_one


Last modified:
Updates:

  1. 2018 Jan 18 04:31:03 PM: Added last name to name
  2. 2018 Jan 18 04:30:57 PM: Added requirement to submit object file and executable (for this assignment ONLY!)


In class last Friday we came up with this list of steps for the assignment.

This program will help you learn how to

Your program should produce output similar to the following.

Sample Run 1:

rucs@/home/nokie> ./homework_one
My name: Joe Jones
Hours: 30
GPA: 3.500
Grade Points: 105.00
Points above 2.0: 45.00

Sample Run 2:

rucs@/home/nokie> ./homework_one
My name: Jack Spratt
Hours: 40
GPA: 1.500
Grade Points: 60.00
Points below 2.0: 20.00

Program to Modify: Modify the program below so that it reflects you.

-- File: homework_one.adb
-- Name: 
-- Date: 

-- Purpose: Calculate points surplus or deficit
--          based on hours taken and GPA

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure homework_one is

   -- Personal data  to be modified
   name: constant String := "Joe Jomes";      -- Student name
   hours_attempted: constant Natural := 30;   -- Hours taken
   gpa: constant Float := 3.5;                -- Current GPA
   -- End of personal data  to be modified

   earned_points: Float;             -- Points actually attained

   -- Requirements
   Required_GPA: constant := 2.0;     -- GPA required to graduate
   required_points: Float;            -- Points needed to graduate

   -- Points calculations
   surplus, deficit: Float;           -- Points above or below required

begin
   -- Calculation
   earned_points := Float(hours_attempted) * gpa;
   required_points := Required_GPA * Float(hours_attempted);

   -- Calculate both even though one will not be needed
   surplus := earned_points - required_points; 
   deficit := required_points - earned_points;

   -- Output
   put_line("Name: " & name);
   put_line("Hours:" & hours_attempted'img);

   put("GPA: ");
   put(item => gpa, fore => 1, aft => 3, exp => 0);
   new_line;

   put("Grade Points: ");
   put(earned_points, 1, 2, 0);
   new_line;

   -- Surplus or deficit
   if earned_points > Required_GPA then
      put("Points above 2.0: ");
      put(surplus, fore => 1, aft => 2, exp => 0);
      new_line;
   else
      put("Points below 2.0: ");
      put(deficit, fore => 1, aft => 2, exp => 0);
      new_line;
   end if;

end homework_one;
Input and output specifications:

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. Another source for gnat is getadanow.com.

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 homework_one.adb homework_one.o homework_one
For this assignment ONLY you are submitting the source file, the object file, and the executable. For future asssignments you will ONLY submit the source!!!

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