Student Performance Objectives:

  • To review formatting an output report file in columnar format
  • To review file input and file output
  • To review the partially-filled 1-D array
  • To use hierarchical user defined structure types
  • To use linear search for an ordered array
  • To use character and string input
  • To implement transactions on a database
  • To use ragged arrays
  • To design a well-formatted report in columnar format

Problem Scenario:

Green Keepers, Inc. is a lawn mowing service that operates primarily in the summer months. The owner has requested a program to help maintain service information about the clients.

For this the first phase of the implementation, the following transactions will be needed:

  • to change a clients name,
  • to add 1 to the current years number of lawn cuttings (service counts) for a client,
  • to view all information including the service history for a single client.

The output report will consist of 3 sections:

  • Section 1: A report consisting of all data records BEFORE changes
  • Section 2: A report consisting of documentation (success or failure) of the transactions
  • Section 3: A report consisting of all data records AFTER changes

Assignment Requirements:

1.The program must include the required documentation (Identification Header, Problem Specification, Problem Analysis) and follow programming documentation guidelines (see A#2). Before each function definition include documentation as shown in A#5:

2.Input is from the ASCII text files Lawn.data and Trans.data. Output is to Report.out. See input file specifications below.

3.The input data must be read until end of file is reached from Lawn.data and stored into a 1-D array of CLIENT structures. The CLIENT declaration must contain a nested (hierarchical) 1-D array structure of type HISTORY for describing a clients service history.

Thereafter, all processing including the report printing must be done against the partially-filled array of CLIENT structures. Only read Lawn.data until end-of-file is reached 1 time! There is a maximum of 30 clients; there is a maximum of 10 histories per client.

4.The records from the file, Trans.data, should be read and processed against the 1-D array of CLIENT structures one after another until end of file is reached in Trans.data. As each transaction is processed, a log of the work is printed in Section 2 of the output report.

5.Use a ragged array to print the description for the client service provided and not the code:

1 = “Full Service”
2 = “Basic”
3 = “Economy”

Usage:

string serviceDescription[] = {DUMMY, Full Service, Basic, Economy};

6.The ordered linear search should be used to locate a client in the CLIENT array using the transaction ID.

7.The file Report.out should be created from the array and contains 3 sections:

Section 1 - a report showing all client data for all clients before transactions are applied

Section 2 - a report describing all transactions as they are being applied against the 1-D client array:

If a transaction code is invalid (not C, not A and not V),

Print the transaction code, Print an error message,
Flush the transaction input line to ‘n’.

If no match for an ID is made,

Print the transaction code (‘C’, ‘A’, ‘V’)
Print the invalid client ID with a suitable error message.

For all other valid transactions,

Print the transaction Code,
Print the client ID and client Name, Print the before and after values.
For, transaction ‘A’, add 1 to the current year’s history service counts.

Section 3 - a report showing all client data for all clients after the transactions

8. Just before the program ends, open LawnNEW.data for output and create the new data file version from the updated 1-D array of CLIENT structures.

Input File: ASCII text file named Lawn.data, stored in ascending order by the client ID in the following format for each client. Client history at (number of histories 1) is the current (most recent) history. see image.

IMPORANT NOTE: the most recent history is at position, Number of Histories -1. In other words the oldest history for a client is at the beginning of the history array for a client.

Input File: ASCII text Trans.data, transactions in any order, fields separated by spaces according to the following formats: see image.

Output File: ASCII text file Report.out, Use good sub-report layout with nice heading, column headings, and formatting. BE SURE AND INCLUDE THE COMPANY NAME IN THE HEADING!

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.