Question
customers.txt reads: Spot Feline 1 2 -1 Iorek Canine 1 4 8 -1 Milo Feline 1 13 -1 Felix Canine 1 7 3 -1 Shadow
customers.txt reads:
Spot Feline 1 2 -1
Iorek Canine 1 4 8 -1
Milo Feline 1 13 -1
Felix Canine 1 7 3 -1
Shadow Canine 1 10 -1
Cosmo Feline 1 11 -1
Bruce Canine 1 12 -1
Jackson Feline 1 9 -1
services.txt reads:
1. 25.00 Exam
2. 50.00 Antibiotic
3. 60.00 Previcox
4. 10.00 Ear-Care
5. 15.00 Vaccinnation-Rabies
6. 100.00 Spay/Neuter
7. 500.00 Knee-Surgery
8. 25.00 Nail-Trim
9. 40.00 Feline-Leukemia-Vaccine
10. 55.00 Canine-5-in-1-Vaccine
11. 55.00 Feline-3-in-1-Vaccine
Program Requirement descriptions (code must include descriptive comments):
Read vet customer and service data and compute total bill. Use arrays of structures to hold data to process.
- 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
- 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.
- 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
- Create a structure to contain the information for the products:
Product Number
Price
Description
Declare the structure in the header file
- 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.
- 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).
- 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).
- 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.
- 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.
- Read and store the service data into the structure array using a function.
- Read and store the customer data in into the structure array using a function.
- You may read the service and customer data in the same function.
- 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.
- 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.
- 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.
- Main should contain function calls only; no data or output processing.
- All functions should be in a separate code file (*.cpp). The assignment will involve 2 cpp files and 1 header file.
- Close all files prior to program end. Close the files using a function.
- 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.
- Each function must have required documentation (pre and post conditions).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started