help me please

' ===========================================================================

' NAME..........: C.R.S. (Car Rental System)

' VERSION.......: 1.00

' DATE CREATED..: Monday, March 20th, 2006

' AUTHOR........: Jared Ramkellowan

' FILE NAMES....: Customer.dat and Cars.dat in same folder as the program.

'

' DESCRIPTION...: This program can be used as a car rental management

'it provides customer and car inventory management system

'as well as the ability to actually rent cars to the

'different customers. This program will be using random

'access files to perform it's duties, as well, the

'ability to display and print of the customer receipt

'will also be available.

' ===========================================================================

' ===========================================================================

'USER DEFINED TYPES SECTION

' ===========================================================================

'

' NAME: CompanyData

' DESCRIPTION: This Structure holds the information

'About the current company. This

'information is saved in the file

'CRS.CFG file.

'

TYPE CompanyData

CompanyNameAS STRING * 60

AddressAS STRING * 60

CITY AS STRING * 30

State AS STRING * 20

ZipCodeAS STRING * 7

TelephoneAS STRING * 14

FaxAS STRING * 14

Email AS STRING * 60

WebsiteAS STRING * 60

END TYPE

' --

' NAME: CustomerData

' DESCRIPTION: Holds Information relative to the

'current customer we'll be renting

'a car to.

' --

TYPE CustomerData

CustomerIDAS LONG

CustomerName AS STRING * 40

Address1AS STRING * 60

Address2AS STRING * 40

CITY AS STRING * 30

State AS STRING * 20

ZipCodeAS STRING * 7

TelephoneAS STRING * 14 ' (###) ###-####

FaxAS STRING * 14 ' (###) ###-####

Email AS STRING * 60

END TYPE

' --

' NAME: CarData

' DESCRIPTION: Holds Information relative to a car

'Information to allow to identify

'a car quickly and easily.

' --

TYPE CarData

CarID AS LONG

CarBrandAS STRING * 16

CarModelAS STRING * 25

CarTypeAS STRING * 20

CarYearAS INTEGER

CarColorAS STRING * 12

LicensePlate AS STRING * 10

IsAvailableAS INTEGER

RentalPriceAS DOUBLE

RentedToAS LONG

RentedOnDate AS STRING * 10

NumberOfDays AS INTEGER

END TYPE

' ===========================================================================

' SUB AND FUNCTION DECLARATIONS

' ===========================================================================

DECLARE SUB ShowMainScreen ()

DECLARE SUB MainMenuSystem ()

DECLARE SUB DrawMenuFrame ()

DECLARE SUB ClearSubArea ()

DECLARE SUB ShowAvailableCars ()

DECLARE SUB ShowRentedCars ()

DECLARE SUB RentACar ()

DECLARE SUB ReturnACar ()

DECLARE SUB GetCustomerData ()

DECLARE SUB FindCustomer ()

DECLARE SUB GetCarData ()

DECLARE SUB FindCar ()

DECLARE SUB ExitCRSSystem ()

DECLARE SUB UpdateCarData (CarID AS INTEGER, CustomerID AS INTEGER, Days AS INTEGER, Availability AS INTEGER)

DECLARE FUNCTION DisplayCustomer% (CustomerID AS INTEGER)

DECLARE FUNCTION DisplayCar% (CarID AS INTEGER, License AS STRING)

DECLARE FUNCTION GetCarRentalPrice# (CarID AS INTEGER)

' ===========================================================================

'VARIABLES SECTION

' ===========================================================================

DIM SHARED CustomerHandle AS INTEGER

DIM SHARED CustomerRecord AS LONG

DIM SHARED CustomerCountAS LONG

DIM SHARED CarHandleAS INTEGER

DIM SHARED CarRecordAS LONG

DIM SHARED CarCountAS LONG

DIM SHARED Company AS CompanyData

DIM SHARED CurrentCarAS CarData

DIM SHARED CurrentCustomer AS CustomerData

' ===========================================================================

' MAIN PROGRAM SECTION

' ===========================================================================

' --

' Get Company Information From The Data Statements

' --

READ Company.CompanyName

READ Company.Address

READ Company.CITY

READ Company.State

READ Company.ZipCode

READ Company.Telephone

READ Company.Fax

READ Company.Email

READ Company.Website

'

' Open Database Files

'

CarHandle = FREEFILE

OPEN "Car.dat" FOR RANDOM AS #CarHandle LEN = LEN(CurrentCar)

CarRecord = 1

CarCount = LOF(CarHandle) / LEN(CurrentCar)

CustomerHandle = FREEFILE

OPEN "Customer.dat" FOR RANDOM AS #CustomerHandle LEN = LEN(CurrentCustomer)

CustomerRecord = 1

CustomerCount = LOF(CustomerHandle) / LEN(CurentCustomer)

'

' Display Main Screen And Menu

'

CALL ShowMainScreen

CALL MainMenuSystem

' -

' Data Statements Used For Company Information

' -

DATA "EASY COME AND GO CAR RENTALS"

DATA "204 EASY GO STREET"

DATA "NEW YORK CITY"

DATA "NEW YORK"

DATA "15477"

DATA "(216) 323-3333"

DATA "(216) 323-3335"

DATA "info@easycomeandgo.com"

DATA "http://www.easycomeandgo.com"

' ==============================================

' NAME.........: ClearSubArea()

' PARAMETERS...: None

' RETURNS......: No Value

' CALLED FROM..: Anywhere needed

' -

' DESCRIPTION..: This sub clears a specific

'area of the screen.

' ==============================================

SUB ClearSubArea

DIM Counter AS INTEGER

FOR Counter = 9 TO 24

LOCATE Counter, 1: COLOR 7, 1: PRINT STRING$(80, " ");

NEXT Counter

END SUB

' ===================================================

' NAME.........: DisplayCar()

' PARAMETERS...: None

' RETURNS......: 0 not found, 1 found, 2 not rented

' CALLED FROM..: From The Main Menu System

'

' DESCRIPTION..: This sub looks for a car in the

'car datafile, if it finds it

'it displays it's data, if not

'a message will be shown. If

'it finds the car but the car

'is not available, it will give

'a message in that regard.

' ===================================================

FUNCTION DisplayCar% (CarID AS INTEGER, License AS STRING)

DIM WorkCarAS CarData

DIM WorkResult AS INTEGER

SEEK #CarHandle, 1

DO WHILE NOT EOF(CarHandle)

GET #CarHandle, , WorkCar

IF WorkCar.CarID = CarID OR WorkCar.LicensePlate = License THEN

LOCATE 16, 21: PRINT STR$(WorkCar.CarYear);

PRINT " " + RTRIM$(WorkCar.CarBrand) + " " + RTRIM$(WorkCar.CarModel)

LOCATE 17, 22: PRINT RTRIM$(WorkCar.CarType) + " " + RTRIM$(WorkCar.CarColor)

LOCATE 18, 21: PRINT STR$(WorkCar.RentalPrice) + " per day"

IF WorkCar.IsAvailable = 1 THEN

WorkResult = 2

ELSE

WorkResult = 1

END IF

EXIT DO

ELSE

WorkResult = 0

END IF

LOOP

DisplayCar% = WorkResult

END FUNCTION

' =================================================

' NAME.........: DisplayCustomer()

' PARAMETERS...: CustomerID AS INTEGER

' RETURNS......: No Value

' CALLED FROM..: From The Main Menu System

' -

' DESCRIPTION..: This sub looks for the customer

'ID and if it finds it, it will

'display the customer information

'or a message that the customer

'could not be found.

' =================================================

FUNCTION DisplayCustomer% (CustomerID AS INTEGER)

DIM WorkCustomer AS CustomerData

DIM IsFoundAS INTEGER

DIM WorkResultAS INTEGER

' --

' WE loop through the customers to find the right one

' --

SEEK #CustomerHandle, 1

DO WHILE NOT EOF(CustomerHandle)

GET #CustomerHandle, , WorkCustomer

IF WorkCustomer.CustomerID = CustomerID THEN

IsFound = 1

EXIT DO

END IF

LOOP

' -

' If We Found The Customer we display information

' -

IF IsFound = 1 THEN

COLOR 14, 1

LOCATE 11, 22: PRINT WorkCustomer.CustomerName

LOCATE 12, 22: PRINT RTRIM$(WorkCustomer.Address1) + " " + RTRIM$(WorkCustomer.Address2)

LOCATE 13, 22: PRINT RTRIM$(WorkCustomer.CITY) + " " + RTRIM$(WorkCustomer.State) + " " + RTRIM$(WorkCustomer.ZipCode)

LOCATE 14, 22: PRINT RTRIM$(WorkCustomer.Telephone)

WorkResult = 1

ELSE

LOCATE 11, 22: COLOR 11, 1: PRINT "Cannot Find The Customer."

WorkResult = 0

END IF

DisplayCustomer% = WorkResult

END FUNCTION

' ======================================================================

' Simple Subroutine to draw the menu frame when going back to the menu

' ======================================================================

SUB DrawMenuFrame

LOCATE 8, 1: COLOR 0, 7: PRINT STRING$(80, " ");

LOCATE 8, 41 - (28 / 2): PRINT " C.R.S. MAIN MENU SYSTEM ";

CALL ClearSubArea

LOCATE 25, 1: COLOR 0, 7: PRINT STRING$(80, " ");

LOCATE 25, 1: COLOR 0, 7: PRINT "MAIN MENU SELECTION MODE";

LOCATE 25, 65: PRINT "DATE: "; DATE$;

LOCATE 10, 28: COLOR 0, 7

PRINT CHR$(201); STRING$(21, CHR$(205)); CHR$(187)

FOR Counter = 11 TO 22

LOCATE Counter, 28: COLOR 0, 7

PRINT CHR$(186); STRING$(21, " "); CHR$(186)

NEXT Counter

LOCATE 23, 28: COLOR 0, 7

PRINT CHR$(200); STRING$(21, CHR$(205)); CHR$(188)

END SUB

' ===============================================

' NAME.........: ExitCRSSystem()

' PARAMETERS...: None

' RETURNS......: No Value

' CALLED FROM..: Exit C.R.S. Menu Option

' --

' DESCRIPTION..: This acquires the information

'for a car from the user and

'then saves it to the car file.

' ===============================================

SUB ExitCRSSystem

DIM Response AS STRING

CALL ClearSubArea

LOCATE 16, 20: COLOR 10, 1: PRINT "Do you really want to quit C.R.S.? (Y/N) ";

COLOR 14, 1

INPUT Response

IF UCASE$(Response) = "Y" THEN

CLOSE #CarHandle

CLOSE #CustomerHandle

COLOR 7, 0

CLS

END

ELSE

CALL ClearSubArea

END IF

END SUB

' ===============================================

' NAME.........: FindCar()

' PARAMETERS...: None

' RETURNS......: No Value

' CALLED FROM..: From The Main Menu System

' --

' DESCRIPTION..: This sub gets one of 4 search

'criteria from the user and

'then searches for a matching

'car in the data file.

' ===============================================

SUB FindCar

DIM WorkLicense AS STRING

DIM WorkBrandAS STRING

DIM WorkModelAS STRING

DIM KeyPressAS STRING

DIM IsFoundAS INTEGER

DIM WorkYearAS INTEGER

DIM WorkCarAS CarData

' --

' Write Screen Header And Footer

' --

LOCATE 8, 1: COLOR 0, 7: PRINT STRING$(80, " ");

LOCATE 8, 41 - (21 / 2): PRINT " C.R.S. CAR MODULE ";

CALL ClearSubArea

COLOR 0, 7

LOCATE 25, 1: PRINT STRING$(60, " ");

LOCATE 25, 1: PRINT "CAR SEARCH FACILITY - CONSULTING";

' -

' Display and Get Search Criterion

' -

LOCATE 11, 2: COLOR 10, 1

PRINT "Please Enter 'ONLY ONE' Of The Criterion:"

LOCATE 13, 2: PRINT " License #....:"

LOCATE 14, 2: PRINT " Car Brand....:"

LOCATE 15, 2: PRINT " Car Model....:"

LOCATE 16, 2: PRINT " Car Year.....:"

COLOR 14, 1

LOCATE 13, 20: INPUT WorkLicense

LOCATE 14, 20: INPUT WorkBrand

LOCATE 15, 20: INPUT WorkModel

LOCATE 16, 20: INPUT WorkYear

' -

' Start The Search Based on Criterion

' -

SEEK #CarHandle, 1

IsFound = 0

' -

' Loop To search for the car

' -

DO WHILE NOT EOF(CarHandle) OR IsFound <> 1

GET #CarHandle, , WorkCar

' --

' Conditional structure to compare the right criteria

' --

IF WorkYear <> 0 THEN

IF WorkCar.CarYear = WorkYear THEN

IsFound = 1

EXIT DO

END IF

ELSE

IF RTRIM$(WorkLicense) <> "" THEN

IF UCASE$(RTRIM$(WorkCar.LicensePlate)) = UCASE$(RTRIM$(WorkLicense)) THEN

IsFound = 1

EXIT DO

END IF

ELSE

IF RTRIM$(WorkBrand) <> "" THEN

IF UCASE$(RTRIM$(WorkCar.CarBrand)) = UCASE$(RTRIM$(WorkBrand)) THEN

IsFound = 1

EXIT DO

END IF

ELSE

IF RTRIM$(WorkModel) <> "" THEN

IF UCASE$(RTRIM$(WorkCar.CarModel)) = UCASE$(RTRIM$(WorkModel)) THEN

IsFound = 1

EXIT DO

END IF

END IF

END IF

END IF

END IF

LOOP

' --

' If we found a matching car we display it's information

' --

CALL ClearSubArea

IF IsFound = 1 THEN

COLOR 10, 1

LOCATE 10, 2: PRINT "Car Number.......:";

LOCATE 11, 2: PRINT "Brand Name.......:";

LOCATE 12, 2: PRINT "Model............:";

LOCATE 14, 2: PRINT "Type Of Car......:";

LOCATE 15, 2: PRINT "Year.............:";

LOCATE 16, 2: PRINT "Color............:";

LOCATE 18, 2: PRINT "License Plate....:";

LOCATE 20, 2: PRINT "Available........:";

LOCATE 21, 2: PRINT "Price (per day)..:";

COLOR 14, 1

LOCATE 10, 20: PRINT WorkCar.CarID

LOCATE 11, 21: PRINT WorkCar.CarBrand

LOCATE 12, 21: PRINT WorkCar.CarModel

LOCATE 14, 21: PRINT WorkCar.CarType

LOCATE 15, 20: PRINT WorkCar.CarYear

LOCATE 16, 21: PRINT WorkCar.CarColor

LOCATE 18, 21: PRINT WorkCar.LicensePlate

IF WorkCar.IsAvailable = 0 THEN

LOCATE 20, 21: PRINT "NO"

COLOR 10, 1

LOCATE 19, 50: PRINT "Customer ID.:"; STR$(WorkCar.RentedTo)

LOCATE 20, 50: PRINT "Rented On...: "; RTRIM$(WorkCar.RentedOnDate)

LOCATE 21, 50: PRINT "Rented For..:"; STR$(WorkCar.NumberOfDays); " day(s)"

COLOR 14, 1

LOCATE 19, 63: PRINT STR$(WorkCar.RentedTo)

LOCATE 20, 64: PRINT RTRIM$(WorkCar.RentedOnDate)

LOCATE 21, 63: PRINT STR$(WorkCar.NumberOfDays); " day(s)"

ELSE

LOCATE 20, 21: PRINT "YES"

END IF

LOCATE 21, 20: PRINT WorkCar.RentalPrice

COLOR 11, 1

LOCATE 23, 20: PRINT "Press Any Key To Go Back To The Menu."

'

' Wait for a key to be pressed

'

KeyPress = ""

DO WHILE KeyPress = ""

KeyPress = INKEY$

LOOP

ELSE

LOCATE 16, 16: PRINT "No Matching Car Found. Press A Key To Return To The Menu."

'

' Wait for a key to be pressed

'

KeyPress = ""

DO WHILE KeyPress = ""

KeyPress = INKEY$

LOOP

END IF

END SUB

' ===============================================

' NAME.........: FindCustomer()

' PARAMETERS...: None

' RETURNS......: No Value

' CALLED FROM..: Exit C.R.S. Menu Option

' --

' DESCRIPTION..: This acquires the information

'for a car from the user and

'then saves it to the car file.

' ===============================================

SUB FindCustomer

DIM WorkPhoneAS STRING

DIM WorkNameAS STRING

DIM KeyPressAS STRING

DIM WorkIDAS LONG

DIM IsFoundAS INTEGER

DIM WorkCustomer AS CustomerData

' --

' Write Screen Header And Footer

' --

LOCATE 8, 1: COLOR 0, 7: PRINT STRING$(80, " ");

LOCATE 8, 41 - (24 / 2): PRINT " C.R.S. CUSTOMER MODULE ";

CALL ClearSubArea

COLOR 0, 7

LOCATE 25, 1: PRINT STRING$(60, " ");

LOCATE 25, 1: PRINT "CUSTOMER SEARCH FACILITY - CONSULTING";

' -

' Display and Get Search Criterion

' -

LOCATE 11, 2: COLOR 10, 1

PRINT "Please Enter 'ONLY ONE' Of The Criterion:"

LOCATE 13, 2: PRINT " Telephone #..:"

LOCATE 14, 2: PRINT " Customer ID..:"

LOCATE 15, 2: PRINT " Customer Name:"

COLOR 14, 1

LOCATE 13, 20: INPUT WorkPhone

LOCATE 14, 20: INPUT WorkID

LOCATE 15, 20: INPUT WorkName

' -

' Start The Search Based on Criterion

' -

SEEK #CustomerHandle, 1

IsFound = 0

'

' We Loop Through To Try To Find The Customer

'

DO WHILE NOT EOF(CustomerHandle)

GET #CustomerHandle, , WorkCustomer

IF WorkID <> 0 THEN

IF WorkCustomer.CustomerID = WorkID THEN

IsFound = 1

EXIT DO

ELSE

IF RTRIM$(WorkPhone) <> "" THEN

IF UCASE$(RTRIM$(WorkCustomer.Telephone)) = UCASE$(RTRIM$(WorkPhone)) THEN

IsFound = 1

EXIT DO

END IF

ELSE

IF RTRIM$(WorkName) <> "" THEN

IF UCASE$(RTRIM$(WorkCustomer.CustomerName)) = UCASE$(RTRIM$(WorkName)) THEN

IsFound = 1

EXIT DO

END IF

END IF

END IF

END IF

END IF

LOOP

' -

' If We Found a Customer, We Display His Information

' -

IF IsFound = 1 THEN

COLOR 10, 1

LOCATE 10, 2: PRINT "Customer Number..:";

LOCATE 11, 2: PRINT "Customer Name....:";

LOCATE 13, 2: PRINT "Address..........:";

LOCATE 15, 2: PRINT "City.............:";

LOCATE 16, 2: PRINT "State............:";

LOCATE 17, 2: PRINT "Zip Code.........:";

LOCATE 19, 2: PRINT "Telephone Number.:";

LOCATE 20, 2: PRINT "Fax Number.......:";

LOCATE 22, 2: PRINT "Email............:";

COLOR 14, 1

LOCATE 10, 21: PRINT WorkCustomer.CustomerID

LOCATE 11, 20: PRINT WorkCustomer.CustomerName

LOCATE 13, 20: PRINT WorkCustomer.Address1

LOCATE 14, 20: PRINT WorkCustomer.Address2

LOCATE 15, 20: PRINT WorkCustomer.CITY

LOCATE 16, 20: PRINT WorkCustomer.State

LOCATE 17, 20: PRINT WorkCustomer.ZipCode

LOCATE 19, 20: PRINT WorkCustomer.Telephone

LOCATE 20, 20: PRINT WorkCustomer.Fax

LOCATE 22, 20: PRINT WorkCustomer.Email

LOCATE 24, 20: PRINT "Press Any Key To Go Back To The Menu."

'

' Wait for a key to be pressed

'

KeyPress = ""

DO WHILE KeyPress = ""

KeyPress = INKEY$

LOOP

ELSE

LOCATE 16, 12: PRINT "No Matching Customer Found. Press A Key To Return To The Menu."

'

' Wait for a key to be pressed

'

KeyPress = ""

DO WHILE KeyPress = ""

KeyPress = INKEY$

LOOP

END IF

END SUB

' ===============================================

' NAME.........: GetCarData()

' PARAMETERS...: None

' RETURNS......: No Value

' CALLED FROM..: Add Car Menu Option

' --

' DESCRIPTION..: This acquires the information

'for a car from the user and

'then saves it to the car file.

' ===============================================

SUB GetCarData

DIM FileHandle AS INTEGER

DIM WorkNumber AS INTEGER

DIM WorkCarAS CarData

' --

' Print Screen Header And Footer

' --

LOCATE 8, 1: COLOR 0, 7: PRINT STRING$(80, " ");

LOCATE 8, 41 - (30 / 2): PRINT " C.R.S. CAR MODULE ";

CALL ClearSubArea

COLOR 0, 7

LOCATE 25, 1: PRINT STRING$(50, " ");

LOCATE 25, 1: PRINT "CAR DATA ENTRY - EDITING";

'

' Inquire Car Information From The User

'

COLOR 10, 1

LOCATE 10, 2: PRINT "Car Number.......:";

LOCATE 11, 2: PRINT "Brand Name.......:";

LOCATE 12, 2: PRINT "Model............:";

LOCATE 14, 2: PRINT "Type Of Car......:";

LOCATE 15, 2: PRINT "Year.............:";

LOCATE 16, 2: PRINT "Color............:";

LOCATE 18, 2: PRINT "License Plate....:";

LOCATE 20, 2: PRINT "Available (0/1)..:";

LOCATE 21, 2: PRINT "Price (per day)..:";

COLOR 14, 1

LOCATE 10, 20: INPUT WorkCar.CarID

LOCATE 11, 20: INPUT WorkCar.CarBrand

LOCATE 12, 20: INPUT WorkCar.CarModel

LOCATE 14, 20: INPUT WorkCar.CarType

LOCATE 15, 20: INPUT WorkCar.CarYear

LOCATE 16, 20: INPUT WorkCar.CarColor

LOCATE 18, 20: INPUT WorkCar.LicensePlate

LOCATE 20, 20: INPUT WorkCar.IsAvailable

LOCATE 21, 20: INPUT WorkCar.RentalPrice

' --

' Save Car Information To Data File

' --

PUT #CarHandle, CarCount + 1, WorkCar

CarRecord = CarRecord + 1

CarCount = LOF(CarHandle) / LEN(WorkCar)

END SUB

' ==============================================

' NAME.........: GetCarRentalPrice()

' PARAMETERS...: CarID AS INTEGER

' RETURNS......: The Price of the Car if found

' CALLED FROM..: Anywhere needed

' -

' DESCRIPTION..: This sub searches for the

'specific car and when found

'gets it's rental price to

'return to the calling sub.

' ==============================================

FUNCTION GetCarRentalPrice# (CarID AS INTEGER)

DIM WorkCarAS CarData

DIM WorkPrice AS DOUBLE

SEEK #CarHandle, 1

DO WHILE NOT EOF(CarHandle)

GET #CarHandle, , WorkCar

IF WorkCar.CarID = CarID THEN

WorkPrice = WorkCar.RentalPrice

EXIT DO

END IF

LOOP

GetCarRentalPrice# = WorkPrice

END FUNCTION

' ===============================================

' NAME.........: GetCustomerData()

' PARAMETERS...: None

' RETURNS......: No Value

' CALLED FROM..: From The Main Menu System

' --

' DESCRIPTION..: This sub Displays the normal

'customer fields, inputs the

'values from the user and adds

'the customer to the data file.

' ===============================================

SUB GetCustomerData

DIM WorkCustomer AS CustomerData

' --

' Write Screen Header And Footer

' --

LOCATE 8, 1: COLOR 0, 7: PRINT STRING$(80, " ");

LOCATE 8, 41 - (26 / 2): PRINT " C.R.S. CUSTOMER MODULE ";

CALL ClearSubArea

COLOR 0, 7

LOCATE 25, 1: PRINT STRING$(60, " ");

LOCATE 25, 1: PRINT "CUSTOMER DATA ENTRY - EDITING";

LOCATE 8, 60: PRINT CarCount

'

' Inquire The Customer Information From The User

'

COLOR 10, 1

LOCATE 10, 2: PRINT "Customer Number..:";

LOCATE 11, 2: PRINT "Customer Name....:";

LOCATE 13, 2: PRINT "Address..........:";

LOCATE 15, 2: PRINT "City.............:";

LOCATE 16, 2: PRINT "State............:";

LOCATE 17, 2: PRINT "Zip Code.........:";

LOCATE 19, 2: PRINT "Telephone Number.:";

LOCATE 20, 2: PRINT "Fax Number.......:";

LOCATE 22, 2: PRINT "Email............:";

COLOR 14, 1

LOCATE 10, 20: INPUT WorkCustomer.CustomerID

LOCATE 11, 20: INPUT WorkCustomer.CustomerName

LOCATE 13, 20: INPUT WorkCustomer.Address1

LOCATE 14, 20: INPUT WorkCustomer.Address2

LOCATE 15, 20: INPUT WorkCustomer.CITY

LOCATE 16, 20: INPUT WorkCustomer.State

LOCATE 17, 20: INPUT WorkCustomer.ZipCode

LOCATE 19, 20: INPUT WorkCustomer.Telephone

LOCATE 20, 20: INPUT WorkCustomer.Fax

LOCATE 22, 20: INPUT WorkCustomer.Email

' -

' Save and Close The Customer File

' -

PUT #CustomerHandle, CustomerCount + 1, WorkCustomer

CustomerRecord = CustomerCount + 1

CustomerCount = LOF(CustomerHandle) / LEN(WorkCustomer)

CLOSE #FileHandle

END SUB

' ===============================================

' NAME.........: MainMenuSystem()

' PARAMETERS...: None

' RETURNS......: No Value

' CALLED FROM..: From The Main Program Section

' --

' DESCRIPTION..: This sub is the main menu and

'logic control subroutine of

'C.R.S. Everything in the

'is available through here and

'only through here.

' ===============================================

SUB MainMenuSystem

DIM MenuArray(1 TO 12) AS STRING

DIM CurrentMenuAS INTEGER

DIM CounterAS INTEGER

DIM CanExitAS INTEGER

DIM KeyboardAS STRING

' -

' Setup The Menu Array

' -

CurrentMenu = 1

MenuArray(1) = " View Available Cars "

MenuArray(2) = " View Rented Cars"

MenuArray(3) = " Rent A Car "

MenuArray(4) = " Return A Car"

MenuArray(5) = STRING$(21, CHR$(196))

MenuArray(6) = " Add A Customer"

MenuArray(7) = " Find A Customer"

MenuArray(8) = STRING$(21, CHR$(196))

MenuArray(9) = " Add A Car"

MenuArray(10) = " Find A Car "

MenuArray(11) = STRING$(21, CHR$(196))

MenuArray(12) = " Exit C.R.S. System "

' --

' Draw Menu Frame

' --

LOCATE 10, 28: COLOR 0, 7

PRINT CHR$(201); STRING$(21, CHR$(205)); CHR$(187)

FOR Counter = 11 TO 22

LOCATE Counter, 28: COLOR 0, 7

PRINT CHR$(186); STRING$(21, " "); CHR$(186)

NEXT Counter

LOCATE 23, 28: COLOR 0, 7

PRINT CHR$(200); STRING$(21, CHR$(205)); CHR$(188)

' --

' Main Loop That Displays The Menu And Awaits Selection

' --

DO WHILE CanExit = 0

' -

' Display Menu Options

' -

FOR Counter = 1 TO 12

LOCATE 10 + Counter, 29

IF Counter = CurrentMenu THEN

COLOR 7, 0

ELSE

COLOR 0, 7

END IF

PRINT MenuArray(Counter)

NEXT Counter

'

' Await User Input From The Keyboard

'

DO WHILE Keyboard = ""

Keyboard = INKEY$

LOOP

'

' Conditional Structure To Manage Key Presses

'

SELECT CASE Keyboard

CASE CHR$(13) ' ENTER KEY

SELECT CASE CurrentMenu

CASE 1 ' SEE AVAILABLE CARS

CALL ShowAvailableCars

CASE 2 ' SEE AVAILABLE CARS

CALL ShowRentedCars

CASE 3 ' RENT A CAR TO A CUSTOMER

CALL RentACar

CASE 4 ' RETURN A CAR TO A CUSTOMER

CALL ReturnACar

CASE 6 ' ADD A CUSTOMER

CALL GetCustomerData

CASE 7 ' FIND A CUSTOMER

CALL FindCustomer

CASE 9 ' ADD A CAR

CALL GetCarData

CASE 10 ' FIND A CAR

CALL FindCar

CASE 12

CALL ExitCRSSystem

END SELECT

CALL DrawMenuFrame

CASE CHR$(0) + CHR$(72) ' UP ARROW

CurrentMenu = CurrentMenu - 1

IF CurrentMenu < 1 THEN

CurrentMenu = 12

END IF

IF LEFT$(MenuArray(CurrentMenu), 1) = CHR$(196) THEN

CurrentMenu = CurrentMenu - 1

END IF

CASE CHR$(0) + CHR$(80) ' DOWN ARROW

CurrentMenu = CurrentMenu + 1

IF CurrentMenu > 12 THEN

CurrentMenu = 1

END IF

IF LEFT$(MenuArray(CurrentMenu), 1) = CHR$(196) THEN

CurrentMenu = CurrentMenu + 1

END IF

END SELECT

Keyboard = ""

LOOP

COLOR 7, 0

CLS

END SUB

' ===============================================

' NAME.........: RentACar()

' PARAMETERS...: None

' RETURNS......: No Value

' CALLED FROM..: From The Main Menu System

' --

' DESCRIPTION..: This sub performs the process

'of renting an available car to

'customer, a check on the car's

'availability is done and if

'the car is rented already, the

'customer's information that

'has the car will be shown

'before a new car number is

'asked for by the system.

' ===============================================

SUB RentACar

DIM WorkCustomerID AS INTEGER

DIM CustomerFound AS INTEGER

DIM WorkCarIDAS INTEGER

DIM CarFoundAS INTEGER

DIM WorkDaysAS INTEGER

DIM CustomerString AS STRING

DIM CarStringAS STRING

DIM WorkCarAS CarData

DIM KeyPressAS STRING

' --

' Write Screen Header And Footer

' --

LOCATE 8, 1: COLOR 0, 7: PRINT STRING$(80, " ");

LOCATE 8, 41 - (26 / 2): PRINT " C.R.S. RENTAL MODULE ";

CALL ClearSubArea

COLOR 0, 7

LOCATE 25, 1: PRINT STRING$(60, " ");

LOCATE 25, 1: PRINT "CAR RENTAL DATA ENTRY - EDITING";

'

' Input Required Information For Car Rental Process

'

LOCATE 10, 2: COLOR 10, 1: PRINT "Customer ID..:"

LOCATE 15, 2: COLOR 10, 1: PRINT "Car ID.......:"

LOCATE 19, 2: COLOR 10, 1: PRINT "Rented Days..:"

LOCATE 21, 2: COLOR 10, 1: PRINT "TOTAL PRICE..:"

LOCATE 10, 22: COLOR 14, 1: INPUT WorkCustomerID

CustomerFound = DisplayCustomer(WorkCustomerID)

LOCATE 15, 22: COLOR 14, 1: INPUT WorkCarID

CarFound = DisplayCar(WorkCarID, "")

LOCATE 19, 22: COLOR 14, 1: INPUT WorkDays

WorkPrice = GetCarRentalPrice#(WorkCarID)

LOCATE 21, 22: COLOR 14, 1: PRINT WorkDays * WorkPrice

' --

' We can use WorkPrice to determine of the car was found

' --

IF CarFound > 0 AND CustomerFound > 0 THEN

CALL UpdateCarData(WorkCarID, WorkCustomerID, WorkDays, 0)

LOCATE 23, 20: COLOR 11, 1:

PRINT " The rental transaction has been updated.";

LOCATE 24, 20: COLOR 11, 1:

PRINT "Press a key to go back to the menu.";

ELSE

LOCATE 23, 20: COLOR 11, 1:

PRINT "The Car Was Not Found, Transaction is Cancelled";

LOCATE 24, 20: COLOR 11, 1:

PRINT "Press a key to go back to the menu.";

END IF

'

' Wait for a key to be pressed

'

KeyPress = ""

DO WHILE KeyPress = ""

KeyPress = INKEY$

LOOP

END SUB

' ===============================================

' NAME.........: ReturnACar()

' PARAMETERS...: None

' RETURNS......: No Value

' CALLED FROM..: From The Main Menu System

' --

' DESCRIPTION..: This sub finds a rented car

'and resets the rented values

'in order to render the car

'available for rental again.

' ===============================================

SUB ReturnACar

DIM WorkCustomerID AS INTEGER

DIM CarResultAS INTEGER

DIM WorkCarIDAS INTEGER

DIM WorkLicenseAS STRING

DIM WorkDaysAS INTEGER

DIM CustomerString AS STRING

DIM KeyPressAS STRING

' --

' Write Screen Header And Footer

' --

LOCATE 8, 1: COLOR 0, 7: PRINT STRING$(80, " ");

LOCATE 8, 41 - (26 / 2): PRINT " C.R.S. RENTAL MODULE ";

CALL ClearSubArea

COLOR 0, 7

LOCATE 25, 1: PRINT STRING$(60, " ");

LOCATE 25, 1: PRINT "CAR RETURN SYSTEM";

'

' As For A Car's ID to search for

'

COLOR 10, 1

LOCATE 11, 2: PRINT "Please enter 'ONLY ONE' of the criteria."

LOCATE 13, 2: PRINT " Car ID........:"

LOCATE 14, 2: PRINT " License Plate.:"

COLOR 14, 1

LOCATE 13, 22: INPUT WorkCarID

LOCATE 14, 22: INPUT WorkLicense

' --

' Display The Car Information If Found

' --

CarResult = DisplayCar(WorkCarID, WorkLicense)

'

' If The Car is found and is a rented car we return it

'

IF CarResult = 1 THEN

CALL UpdateCarData(WorkCarID, 0, 0, 1)

LOCATE 23, 20: COLOR 11, 1:

PRINT " The car has been successfully returned.";

LOCATE 24, 20: COLOR 11, 1:

PRINT "Press a key to go back to the menu.";

' -

' If The Car is found and not rented we cancel

' -

ELSEIF CarResult = 2 THEN

LOCATE 23, 15: COLOR 11, 1:

PRINT "The Car is not a rented car, Transaction is Cancelled";

LOCATE 24, 20: COLOR 11, 1:

PRINT "Press a key to go back to the menu.";

' --

' If the car was not found we cancel as well

' --

ELSE

LOCATE 23, 20: COLOR 11, 1:

PRINT "The Car Was Not Found, Transaction is Cancelled";

LOCATE 24, 20: COLOR 11, 1:

PRINT "Press a key to go back to the menu.";

END IF

'

' Wait For A KeyPress Before Going Back To The Menu

'

KeyPress = ""

DO WHILE KeyPress = ""

KeyPress = INKEY$

LOOP

END SUB

' ===============================================

' NAME.........: ShowAvailableCars()

' PARAMETERS...: None

' RETURNS......: No Value

' CALLED FROM..: From The Main Menu System

' --

' DESCRIPTION..: This sub Displays All of the

'cars who's availability flag

'has a value of 1.

' ===============================================

SUB ShowAvailableCars

DIM WorkCarAS CarData

DIM WorkString AS STRING

DIM LineCounter AS INTEGER

DIM KeyPressAS STRING

' --

' Write Screen Header And Footer

' --

LOCATE 8, 1: COLOR 0, 7: PRINT STRING$(80, " ");

LOCATE 8, 41 - (20 / 2): PRINT " C.R.S. CAR MODULE ";

CALL ClearSubArea

COLOR 0, 7

LOCATE 25, 1: PRINT STRING$(60, " ");

LOCATE 25, 1: PRINT "AVAILABLE CAR LISTINGS";

' -

' Open Car Datafile and Show Available Cars

' -

SEEK #CarHandle, 1

LOCATE 9, 1: COLOR 15, 1

PRINT " IDLICENSE# YEAR BRAND/MODEL DESCRIPTION PRICE"

PRINT " ====== ======== ==== =================== ============================ ========"

LOCATE 11, 1: COLOR 10, 1

DO WHILE NOT EOF(CarHandle)

GET #CarHandle, , WorkCar

IF WorkCar.IsAvailable = 1 THEN

PRINT USING " ######"; WorkCar.CarID;

PRINT TAB(9); RTRIM$(WorkCar.LicensePlate);

PRINT TAB(17); WorkCar.CarYear;

PRINT TAB(23); RTRIM$(WorkCar.CarBrand) + " " + RTRIM$(WorkCar.CarModel);

PRINT TAB(43); RTRIM$(WorkCar.CarType) + " " + RTRIM$(WorkCar.CarColor);

PRINT TAB(72); USING "$####.##"; WorkCar.RentalPrice

LineCounter = LineCounter + 1

IF LineCounter > 13 THEN

LOCATE 23, 1: COLOR 15, 1

PRINT " ====== ======== ==== =================== ============================ ========"

LOCATE 24, 24: COLOR 12, 1:

PRINT "Press Any Key To see More Cars";

DO WHILE KeyPress = ""

KeyPress = INKEY$

LOOP

KeyPress = ""

CALL ClearSubArea

LOCATE 10, 1: COLOR 10, 1

LineCounter = 0

END IF

END IF

LOOP

' --

' Wait For A Keypress to go back to the menu

' --

LOCATE 23, 1: COLOR 15, 1

PRINT " ====== ======== ==== =================== ============================ ========"

LOCATE 24, 22: COLOR 11, 1:

PRINT "Press Any Key To Go Back To The Menu";

DO WHILE KeyPress = ""

KeyPress = INKEY$

LOOP

END SUB

SUB ShowMainScreen

WIDTH 80, 25

COLOR 7, 1

CLS

' --

' Display Screen Header

' --

LOCATE 1, 1: COLOR 15, 13: PRINT STRING$(80, " ");

LOCATE 1, 1: COLOR 15, 13: PRINT "C.R.S. (Car Rental System)"

LOCATE 1, 69: COLOR 14, 13: PRINT "Version 1.00"

' --

' Show Company information

' --

LOCATE 2, 1: COLOR 7, 1: PRINT STRING$(80, CHR$(196))

LOCATE 3, 55: COLOR 11, 1: PRINT "TELEPHONE: "; RTRIM$(Company.Telephone)

LOCATE 3, 2: COLOR 11, 1: PRINT RTRIM$(Company.CompanyName)

LOCATE 4, 55: COLOR 11, 1: PRINT "FAX: "; RTRIM$(Company.Fax)

LOCATE 4, 2: COLOR 11, 1: PRINT RTRIM$(Company.Address)

LOCATE 5, 2: COLOR 11, 1: PRINT RTRIM$(Company.CITY)

LOCATE 5, 80 - LEN(RTRIM$(Company.Email)): PRINT RTRIM$(Company.Email)

LOCATE 6, 2: COLOR 11, 1: PRINT RTRIM$(Company.State) + " " + RTRIM$(Company.ZipCode)

LOCATE 6, 80 - LEN(RTRIM$(Company.Website)): PRINT RTRIM$(Company.Website)

LOCATE 7, 1: COLOR 7, 1: PRINT STRING$(80, CHR$(196))

' --

' Show Subscreen Header Information

' --

CALL DrawMenuFrame

END SUB

' ===============================================

' NAME.........: ShowRentedCars()

' PARAMETERS...: None

' RETURNS......: No Value

' CALLED FROM..: From The Main Menu System

' --

' DESCRIPTION..: This sub Displays All of the

'cars who are already rented to

'other customers.

' ===============================================

SUB ShowRentedCars

DIM WorkCarAS CarData

DIM WorkString AS STRING

DIM LineCounter AS INTEGER

DIM KeyPressAS STRING

' --

' Write Screen Header And Footer

' --

LOCATE 8, 1: COLOR 0, 7: PRINT STRING$(80, " ");

LOCATE 8, 41 - (20 / 2): PRINT " C.R.S. CAR MODULE ";

CALL ClearSubArea

COLOR 0, 7

LOCATE 25, 1: PRINT STRING$(60, " ");

LOCATE 25, 1: PRINT "RENTED CAR LISTINGS";

' -

' Open Car Datafile and Show Rented Cars

' -

SEEK #CarHandle, 1

LOCATE 9, 1: COLOR 15, 1

PRINT " IDLICENSE# YEAR BRAND/MODEL DESCRIPTION PRICE"

PRINT " ====== ======== ==== =================== ============================ ========"

LOCATE 11, 1: COLOR 10, 1

DO WHILE NOT EOF(CarHandle)

GET #CarHandle, , WorkCar

IF WorkCar.IsAvailable = 0 THEN

IF WorkCar.CarID <> 0 THEN

PRINT USING " ######"; WorkCar.CarID;

PRINT TAB(9); RTRIM$(WorkCar.LicensePlate);

PRINT TAB(17); WorkCar.CarYear;

PRINT TAB(23); RTRIM$(WorkCar.CarBrand) + " " + RTRIM$(WorkCar.CarModel);

PRINT TAB(43); RTRIM$(WorkCar.CarType) + " " + RTRIM$(WorkCar.CarColor);

PRINT TAB(72); USING "$####.##"; WorkCar.RentalPrice

END IF

LineCounter = LineCounter + 1

IF LineCounter > 13 THEN

LOCATE 23, 1: COLOR 15, 1

PRINT " ====== ======== ==== =================== ============================ ========"

LOCATE 24, 24: COLOR 12, 1:

PRINT "Press Any Key To see More Cars";

DO WHILE KeyPress = ""

KeyPress = INKEY$

LOOP

KeyPress = ""

CALL ClearSubArea

LOCATE 10, 1: COLOR 10, 1

LineCounter = 0

END IF

END IF

LOOP

' --

' Wait For A Keypress to go back to the menu

' --

LOCATE 23, 1: COLOR 15, 1

PRINT " ====== ======== ==== =================== ============================ ========"

LOCATE 24, 22: COLOR 11, 1:

PRINT "Press Any Key To Go Back To The Menu";

DO WHILE KeyPress = ""

KeyPress = INKEY$

LOOP

END SUB

' ===============================================

' NAME.........: UpdateCarData()

' PARAMETERS...: CarIDAS INTEGER

'CustomerID AS INTEGER

'DaysAS INTEGER

' RETURNS......: No Value

' CALLED FROM..: When a car is rented.

' --

' DESCRIPTION..: This Subroutine updates the

'car information with the

'proper information pertaining

'to the rental transaction that

'has just been performed.

' ===============================================

SUB UpdateCarData (CarID AS INTEGER, CustomerID AS INTEGER, Days AS INTEGER, Availability AS INTEGER)

DIM WorkCarAS CarData

DIM RecordNumber AS LONG

SEEK #CarHandle, 1

RecordNumber = 1

'

' Loop through the records until we find the car

'

DO WHILE NOT EOF(CarHandle)

GET #CarHandle, , WorkCar

'

' If it's the right Car, update the fields and save

'

IF WorkCar.CarID = CarID THEN

WorkCar.RentedTo = CustomerID

WorkCar.NumberOfDays = Days

WorkCar.IsAvailable = Availability

PUT #CarHandle, RecordNumber, WorkCar

END IF

RecordNumber = RecordNumber + 1

LOOP

END SUB

[41062 byte] By [jedra] at [2007-10-2 16:24:11]
# 1
There is no question.And that isn't java. As a guess it looks like Cobol.
jschella at 2007-7-13 17:21:58 > top of Java-index,Other Topics,Algorithms...
# 2
well actually its a program written in Qbasic, yes i know it is very old. Well i need somee help in creating an algorithm of this program, please help
jedra at 2007-7-13 17:21:58 > top of Java-index,Other Topics,Algorithms...
# 3
I would guess that this is homework.If not then my next guess would be that what you actually want is pseudo code. But given the simplicity of the program one would wonder why the job wouldn't just be to write the program itself in java.
jschella at 2007-7-13 17:21:58 > top of Java-index,Other Topics,Algorithms...
# 4
well yes its a pseudocode i need. If you all don't want to help me can u atleast give me a outline or something because i'm, really bad at pseudocode.Please help me , i need to get this done by tomorrow.Please Help
jedra at 2007-7-13 17:21:58 > top of Java-index,Other Topics,Algorithms...
# 5

> well yes its a pseudocode i need. If you all don't

> want to help me can u atleast give me a outline or

> something because i'm, really bad at

> pseudocode.Please help me , i need to get this done

> by tomorrow.Please Help

Then http://www.rentacoder.com/ is a better option for you.

prometheuzza at 2007-7-13 17:21:58 > top of Java-index,Other Topics,Algorithms...
# 6

> well yes its a pseudocode i need. If you all don't

> want to help me can u atleast give me a outline or

> something because i'm, really bad at

> pseudocode.Please help me , i need to get this done

> by tomorrow.Please Help

The point of homework is to provide practice in understanding the concept.

Pseudo code is also very free form. And I doubt your teacher expects you to show up with anything except the form that he showed you.

jschella at 2007-7-13 17:21:58 > top of Java-index,Other Topics,Algorithms...