Due: midnight Sunday of week 4 Note: This program is again longer than the previous assignment, so begin working on it as SOON as possible.

Due: midnight Sunday of week 4 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 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. Submission Submit: – your program code – any data files used to test your code to the Wk 4 – Assn 3 folder in the Dropbox area of the online course, by midnight, Sunday of week 4 (next week). WARNING: Your program will NOT be accepted if it: does not compile

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.

Click Here to Make an Order Click Here to Hire a Writer