Write a program to help the use and manage the file

Assignment Help Programming Languages
Reference no: EM131187847

Programming Assignment (covers array of records and unordered list searching)

Note: This program is again longer than the previous assignment, so begin working on it as SOON as possible. You will have 11 days to complete it.

A car rental company maintains records about the cars they rent in a file named RENTALS.TXT.

Data stored about each car includes: the license plate number, the mileage, and whether the car is currently rented, stored as follows:

Data Field Data Type

license string type (six characters: 2 letters followed by 4 digits)

mileage integer

rented boolean (within the program)

Sample RENTALS.TXT data Lines:

XY1111 6530 0

AA1234 12444 0

KQ2222 78511 1

Note that the ordinal value of the boolean rented value is stored in the data file (false = 0, true =1). This enables the program to simply write the data to the file from the boolean type field, with no conversion.

Write a program to help the use and manage the file. The data from the file will be stored during program execution as an array of records, with one record (struct) for each. The array should be declared to hold up to 500 records.

Program Implementation

After displaying a short program introduction, begin the program by asking the user whether they want to use existing information. Example:

Load existing data from a file (Y/N)?

If the user chooses to use existing data, the program will try to read the data from a previously stored data file RENTALS.TXT into an array of records.

The program will check to see if the file exists, before trying to read from it. If the file doesn't exist, the program will present an error message about the file, and ask the user whether he wishes to exit the program, or proceed starting with no data.

If the file exists, the program will read the data from the file into an array of records. When reading data from an existing data file, you may assume that all data in the file is valid and properly formatted, so you do not need to error check it.

NOTE: Storing the boolean value for the rented field will be a 2-step process.

First read the integer number into a temporary integer variable.

Then use static_cast to convert the integer to a boolean and store it in the array.

As you read the data from the file, keep track of the number of cars stored. Your program should error check that there are not too many data lines in the input data file, so that the data will not overrun the array boundaries. If there are over 500 data lines in the input file, issue an error message that further listings will be ignored, and do not read any more data records from the file.

AFTER all the car records have been read from the data file into the array of records

(OR if the file does not exist and the user chooses to continue anyway with an initially empty array),

Give the user a menu of choices, as follows. Use a mnemonic letter for each menu option (NOT numbers) with the letter listed to the left of the menu option description:

Show Cars (to the screen)

If the array is empty, simply display a message stating there are no cars stored.

Otherwise, display all data in columns, with one line per listing.

Display the rented status in a word, not a letter or boolean ordinal value.

Include column headers for each data item.

Sample output lines (use this format):

License

Number Mileage Rented

------ -------- ------

XY1111 65300 no

AA1234 12444 no

KQ2222 8511 yes

Add cars(s) to the array

a) Add a new car to the array (if there is still room in the array).

Call a separate user-defined function to read each data item for one record.

b) Loop, adding listings to the array until the user says s/he is done, OR until the max of 500 cars has been entered.

NOTE: Once the array contains 500 listings, do not ask whether to add another!

The program MUST error check all user input, as detailed below.

Write a separate function to read and validate each data field entered by the user (the prompt, read and validation should all be done from inside the function).

If the data entered by the user is invalid, the function should issue an error message stating why it is invalid, and prompt the user to re-enter the information. Each function should loop and re-prompt for the item, until it is valid.

The Add function will call each of the three input data reading functions that reads one data item. As each function has read and validated the required data, the validated data will be returned to the Add function for storage in a field of a record within the array.

Required error checking:

- Validate the license number format

The string must be 6 characters long and contains only letters and digits

(and no spaces), in the correct location (2 letters followed by 2 digits)

NOTES:

In order to read a license and verify that it does not contain spaces, you will need to use getline (covered in text Chapter 3) because the extraction operator (>>) will only read strings up to the first whitespace.

String character error checking must be performed using loops to examine each character, not brute force. Remember that each character of a string can be accessed using an index, just like an array.

- Verify the mileage is a positive, non-zero value.

- Verify that a valid value is entered for rented

The program should ask the user whether the car is rented, and tell the user how to enter the answer (e.g. Is the car currently rented (Y/N)?)

But make sure that the value converted to a boolean before being stored into the array, no matter how the input is read from the user.

Delete a listing

If the array is empty, simply display a message stating there are no cars stored.

If the array contains listings:

a) Display License Numbers of all cars stored, as choices for user

b) Ask the user for the License Number of the car to delete

c) Read the entered License Number and validate the format

(use the License Number reading function created for Adding a Car)

d) Find the License Number in the array

e) If the License Number is found, delete the record from the ARRAY

Reminder: Deleting from arrays was covered in online content sections 3.4.3 and 3.4.4.

f) Display a message confirming which listing has been removed,

or stating that the License Number could not be found.

Exit the program

When the user chooses to exit, the program should ask whether to save/re-save the data to the RENTALS.TXT file before exiting, and do so if requested (overwriting the original data file).

If the user chooses NOT to save, simply exit (but first issue message that the user will lose all changes made).

Each time a menu choice is entered, the program will error check the user has entered a valid choice, before performing the task, and will issue an error message if the choice is not valid.

The program will loop, performing menu tasks, until the user chooses Exit.

NOTE: After reading the data from the file at the beginning of the program (if existing data was chosen), the file should not be accessed again until the end of the program, and then only if the user decides to re-save the data. All of the modifications will be done to the data in the array of records only (i.e. show, add, and delete menu choices will NOT access the file!)

NOTE: You will be modifying this program for a later assignment, so take care in the initial design.

Program Notes:

1. Your program must conform to all CS362 Coding Standards specified in Content section 1.4.

2. This program should be of modular design (minimum of TEN functions that have arguments or return values), use proper parameter passing and prototypes. The module breakdown should be logical, with main doing little more than call other functions, and the other functions each performing only one well-defined task.

3. Descriptive function, constant, and variable names should be used. Constants/variables should be commented. All fixed values should be defined as constants.

4. All code will be structured C++ code. Object-oriented programming (classes, templates, etc) will not be used.

Reference no: EM131187847

Questions Cloud

Develop a human resources strategic plan : Coffee shop human strategic plan- Develop a human resources strategic plan. Indicate how you will consult with the relevant managers
Conduct an analysis to compare the mean level of family : Conduct an analysis to compare the mean level of family involvement in science homework assignments of TIPS and ATIPS students. Use α = .05. Make a practical conclusion.
Social media conference and attending a panel discussion : You are at a social media conference and attending a panel discussion on current trends.
Describe some planning and control activities : Pick any major television network and describe some planning and control activities that its managers would engage in?
Write a program to help the use and manage the file : Write a program to help the use and manage the file. The data from the file will be stored during program execution as an array of records, with one record (struct) for each. The array should be declared to hold up to 500 records.
Protection of the environment : What legal and ethical responsibilities do companies have regarding the protection of the environment? Cite a legal or ethical guideline that has been enacted to protect the environment and the circumstances under which or reasons why it was writt..
Define the statute of frauds and discuss legislative intent : Define the Statute of Frauds and discuss it's legislative intent (why is this law necessary and what is it's purpose).
Evaluate 200 ?nished products : Prior to conducting this experiment, the man- ager believed the variance in inspection errors was lower for experienced inspectors than for novice inspectors. Do the sample data support her belief? Test using α = .05.
Information deficiencies in today technology : Why do you think companies have information deficiencies in today's technology driven world?

Reviews

Write a Review

Programming Languages Questions & Answers

  Develop an interactive e-learning tool in english language

Write a simple description about the program H. Design and display the screenshot of each form and label the different objects - develop an interactive e-learning tool in English language learning for kids

  This is a programming assignment and it needs you to write

this is a programming assignment and it requires you to write the pseudocode for a program that solves the following

  Program-visual basic to compute tips for services rendered

Write a program in Visual Basic 2010 to compute tips for services rendered. The program should request the person's occupation, the amount of the bill and the percentage tip

  Create an application in which a user can enter a phone book

Create an application in which a user can enter a phone book entry, including the following elements

  Program to displays the sum of the integer numeric values

Design a program that displays the sum of the integer numeric values stored in two arrays, in a tabular format. The design defines two arrays of the same size (each array has 10 elements).

  Program for an automatic teller machine that dispenses money

The user should enter the amount desired (a multiple of ten dollars) and the machine dispenses this amount using the least number of bills.

  Write program using ias instruction set

Form the array C such that C(I)=A(I)+B(I) for I=1,2,...,1000. using IAS instruction set, write down program for this problem with assembly.

  Write advantages of external css and internal css

Write down the advantages of external CSS compared to internal CSS? Describe conditions in which each is suitable type.

  How does it differ from the implementation of the class?

what is the public interface of the counter class in section instance variables and encapsulation?

  Read data from a file into our program and search by title

I need help getting the data from the data file to work correctly with the program. Please see the attached documents.

  Develop a company logo application

Copying the template to your working directory. Copy the directory C: Exampl esTutori al 26Exerci sesCompanyLogo to your C: Si mpl yVB2008 directory.

  Lunix

Compare the total number of links in a 20 node network for:

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd