FloridaTech - College of Engineering

CSE1001 - LABORATORY


Lab Assignment 14 : Arrays


To be submitted in the lab

Problem :
Department Store Problem

The customer credit manager of the Greenly Department Stores has requested a new program to perform the weekly update of the customer account file. This account file contains information on all of the customer's who have charge account with the company. A customer's account must be changed when a purchase is charged or a payment is made. An account must be also be changed when the credit manager raises or lowers a customers credit limit. The data entry staff enters all changes into a text file. Once a week the items in this text file are used to bring the accounts up to date.

Input : 

1. A sequential file(Old_Master.Dat) containing an account number, a name, an address,
   a credit limit, and a current balance for each customer.
2. A text file(Transaction.txt) . Each line in this file contains the information for
   a single customer transaction. This information includes 
     a.Account Number-A unique number that identifies the customer.
     b.Transaction Type-The word Payment, Charge, or Limit.
     c.Transaction Amount-A positive float value.

Output :

1. A new sequential file(New_Master.Dat) that contains all of the updated customer information.
2. A text file(Report.txt) containing a line for each customer whose balance is over his or her assigned 
   credit limit. This line should contain the account number, customer name, and the amount 
   the balance is over the credit limit.  

Your Task :

update.adb

create.adb

Part 1

Modify the update.adb and create.adb so that the type declarations are declared in the specification package called Customer_Accounts in the file Customers_Accounts.adb. The program create.adb and update.adb would include this package.

create.adb : To create the Old_Master.Dat file
update.adb : To create the New_Master.Dat file
Customer_Accounts.ads:To contain the specification package which has declarations in it.

Steps :

1. To make a file called Customer_Accounts.ads
..package Customer_Accounts is ....

.......subtype Name_String is String (1..5);
.......subtype Address_String is String (1..5);
.......subtype State_String is String (1..2);

....type Name_Rec is -- For customer name
.......record
.........First : Name_String;
.........Last : Name_String;
....... end record;

....type Address_Rec is -- For customer address
.......record
........Street : Address_String;
........City : Address_String;
........State : State_String;
........Zip : Positive;
......end record;

....type Customer_Rec is -- Customer Account information
.......record
.........Account_Number : Positive;
.........Name : Name_Rec;
.........Address : Address_Rec;
.........Credit_Limit : Float;
........Balance : Float;
......end record;

2. Compile the program Customer_Accounts.ads

3. Remove the declarations from create.adb and include the statement "with Customer_Accounts" at the beginning.

4. Remove the declarations from update.adb and include the statement "with Customer_Accounts" at the beginning.



Part 2 : Arrays

Problem : The final exam in your psychology class is 30 multiple-choice questions. Your instructor says that, if you write the program to grade the finals, you won't have to take it.

Input :(Input.txt) The first data line contains the key to the exam.The correct answers are the first 30 characters; they are followed by an integer number that says how many students took the exam (call it N).
The next N lines contain student answers in the first 30 character positions, followed by the student's name in teh next 10 character positions.

Output : For each student - the student's name; followed the correct answers; followed by PASS if the number correct is 60 percent or better, or FAIL otherwise.

The mutiple choice questions have choices 'a' to 'd'.

Example : The Input.txt has

aaaaabacdbdbacdbadbdccdadbabdb 5
aaabcdbcdadcbdcdbadbcdbcabdcdd Henry Hank
abcdbcbbdbcbdabdbcdbdbcdbbdcbc Larry Geoge
bcdabcbdbcbcbabbcbdbabcbdbccbb Tulip Wash
adcbdbcbabcdbdcbabcdbbcbdbcbda Mike Angles
abcbdbcbabbcbdbcbabcdbdabcdbdc Tom Woodes

The output is 

Henry Hank 9 FAIL
Larry Hank 5 FAIL
Tulip Geoge 5 FAIL
Mike Angles 9 FAIL
Tom Woodes 8 FAIL

Example : Simple.adb


Professor:Dr.Stansifer
G.S.A : Rishi Gupta
Last Modified :4/17/99