In-class Lab Assignment

October 5, 2006

 

NOTE:  This program is to be completed in lab and submitted to the Digital Dropbox at the end of the class.  Name your submission,  yourName14.adb.   IF you have not successfully completed it, submit it anyway.  Then finish it before Tuesday and re-submit it with a comment saying “final version”.

 

Write an Ada program which will read integers from the keyboard and insert them into a linked list, keeping them in ascending order at all times.  There will be 7 integers.

You should print the entire list after each insertion.  The numbers may arrive in any order.  NOTE:  this program does not use an array.  It uses a linked list.  Refer to the notes from Tuesday’s class to remind yourself how to declare pointers and cells.

 

For example if the numbers are :  27, 13, 15, 68, -5, 23  0

 

Prompt the user to enter an integer

Read the first number:  27

Insert the number into the list

Print the one item list:  27

Prompt the user to enter an integer

Read the next number :  13

Insert the number into the list

Print the two item list::  13   27

Prompt the user to enter an integer

Read the next number:  15

Insert the number into the list

Print the three item list :  13  15  27

Prompt the user to enter an integer

Read the next number: 68

Insert the number into the list

Print the four item list  13  15  27  68

etc.

 

The data above is only sample data.  You do not know what number I will type in.