CIS17 - Assignment on arrays

 

Problem #1:  I am buying tickets to a show.  The two variables are seating on the floor (code 1) or in the balcony (code 2) and the type of production.  Productions are assigned a code of 1, 2, or 3 depending on the anticipated demand.

 

 

Production Type 1

Production Type 2

Production Type 3

Floor (code 1)

100

75

50

Balcony (code 2)

80

60

35

 

In my pseudocode I have the following:

 

Loop

   Move the idno, name and address to the output line

·        You need to insert a line of code using subscripts/indexes/pointers that will use the production code on the input (prodCd)on the input and the location code on the input (locCd)  to move the price from the array/table to the output line. Lets call the name of the price in the table just price. Tell me whether you are setting up the codes so it will go to the row and then the column or the column and then the row.

  Write the line

   Read another record

End Loop

 

 

Problem #2:  The college uses codes like CIC, CIN, CIW, CIB, CIX, CIM, CIT to determine which option the student is in.  For this problem assume that the record for the student on the file contains one of these codes and that you want to go to the array/table and print out the name (please note I am not sure I got the codes right - just go with my guesses).

 

Option Code

Option Name

CIC

Computer Programming

CIN

Computer Networking

CIW

Webmaster

CIB

Business Information Systems

CIX

Computer Science Transfer

CIM

Multimedia and the Internet

CIT

Information Systems Transfer

 

For our purposes we are going to call the option code on the input optIN, the option code in the array optArray and the option name in the array optName.

 

You need to write the pseudocode search to take the option code from the input, search the table and write the option name on the output line.  If the option does not exist, you want to write an appropriate message to indicate that it was an invalid code.

 

Extra Credit:

 

If you changed the order of the option codes and put them in sequential order, you could write an early exit routine that would let you exit when you know that a match cannot be found even though you have not necessarily checked all of the options in the table. Show the revised table and write the pseudocode to handle an early exit.