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

  Find the proper syntax for plotting the graph

Find the proper syntax for plotting the graph of |x|+|y|=1 ranging from -1 to 1 - Hint: you do not need to create x and y.

  Describes an accusation of fact that a crime

Describes an accusation of fact that a crime has been committed.a. attrition

  About html

Hyper Text Markup Language.

  Write function is pseudocode to calculate area of triangle

Write down the function is pseudocode called calculate area which calculates the area of a triangle. Algorithm for area computation is this: area=1/2*base*height.

  Statement to read variables of type double

Suppose two variables p1 and p2 of type POINT, with two fields, x and y, both of type double, have been declared. Write a statement that reads values for p1 and p2 in that order.

  Differences between sql and procedural programming

Describe some of the differences between SQL and procedural programming languages such as C and VB

  Improve jsp functionto traverse and list on the screen

Create an XHTML document with the JavaScript code to open and build the DOM tree for orders.xml as in the seminar, but them also loads in and builds another DOM tree for another fileâ?¦ say orders2.xml as shown below

  Parking garage program to permit user to enter type of car

Parking garage program to permit user to enter type of car in addition to number of hours in parking garage. Program can be use for any number of customers.

  Create program that uses array of shape

Create a program that uses an array of Shape references to objects of each concrete class in the hierarchy. The program should print a text description of the object to which each array elements

  Write program uses while loop to output all odd numbers

Write a program that uses while loop to perform the following steps: Output all the odd numbers between firstnum and secondnum inclusive.

  Build a program for a shopping plazz

Build a program for a shopping plaza. Shopping store which allows its customers to shop in its showrooms. Peter england, levis, and kids kemp and finally generate the bill amount to be paid

  Write program to open file for reading

Write the program to open file for reading which has twenty (20) rows and in each row there are three (3) columns. After reading each row call user-defined function to display each row.

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