Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Programming Assignment 1 Structures, arrays of structures, functions, header files Program description: Read vet customer and service data and compute total bill. Use arrays of

Programming Assignment 1

Structures, arrays of structures, functions, header files

Program description:

Read vet customer and service data and compute total bill. Use arrays of structures to hold data to process.

  1. You are to read a data file (provided) containing customer data for veterinary services provided and calculate the total bill.

The customer file consists of several rows of data that contain:

Pet name (single word for simplicity), Pet Type (species), any number of services, -1 indicating end of the record

The service number is a number representing a provided service. This will correspond to a number in the services file, however, there may be errors in the customers file, i.e., a service number may not exist in the services file.

For example:

Fluffy Feline 1 3 5 -1

Iorek Canine 2 3 5 -1

  1. Create a structure to contain the information for a customer:

Pet Name

Pet Type

Total Bill

Number of Services

Description of Services (a maximum array size of 5)

Declare the structure in a header file.

  1. You are also to read a data file (provided) containing service information, which consists of a service number, a price and a description.

For example:

1 15.95 Exam

2 12.22 Antibiotics

Service 1 has a price of 15.95 and a description of Exam, service 2 has a price of 12.22 and a description of Antibiotics

  1. Create a structure to contain the information for the products:

Product Number

Price

Description

Declare the structure in the header file

  1. Declare the structures for the customer and service data in the header file. Declare an array variable for each of the customer and service structures LOCALLY in main. Declare an array size for the customer data as 30; for the service data as 50.

  1. Read and store the service data into the service structure array. Read until end of file. Use a counter to count and track how many rows read. Pass the counter into any processing functions that loop through structure array (do not use a global variable).

  1. Read and store the customer data into the customer structure array. Read until end of file. Use a counter to count and track how many rows read. Pass the counter into any processing functions that loop through the structure array (do not use a global variable).

  1. Calculate the total bill for each customer while reading the data and then store in the structure. You ARE NOT to store the product/number sold pairs in the customer array for each customer, you are to store the service descriptions in the services array inside the structure. The total bill calculation will involve reading the service data into the service array structure first and looking up the price based on the service number while reading the customer data.

  1. Also, tally the number of services and store in the customer structure to indicate how many services were provided to the customer for the output function.

  1. Read and store the service data into the structure array using a function.

  1. Read and store the customer data in into the structure array using a function.

  1. You may read the service and customer data in the same function.

  1. Process the all customer data using a function. This may be included in the read function. Checking for valid service numbers. If an invalid service number is encountered in the customer data, write the invalid service number to an error file with an appropriate message of your choice. DO NOT include the service in the total bill calculation.

  1. Using a function, output the computed bill data to the console (cout) and to an output data file including the following information. This must be a function called from main:

Pet Name Pet Type Total Bill Services (list all services)

Include dollar signs before money values and ensure each line of data is neat and readable. All monetary values must have two decimal places.

  1. Use a function to open all input and output files. Request all file names from the user EXCEPT the error file, which you may choose and hard code in the program.

  1. Main should contain function calls only; no data or output processing.

  1. All functions should be in a separate code file (*.cpp). The assignment will involve 2 cpp files and 1 header file.

  1. Close all files prior to program end. Close the files using a function.

  1. All structure DECLARATIONS, global constants and function prototypes MUST be in a header file. Include the header file in the program. DO NOT CODE THE FUNCTIONS IN THE HEADER FILE. Functions MUST be coded in the .cpp file AFTER main.

  1. Each function must have required documentation (pre and post conditions).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students explore these related Databases questions

Question

The Nature of Language

Answered: 3 weeks ago