Question: Write a c++ program that can be used to create a detailed billing report for a company that provides tax consultations for customers: The information
Write a c++ program that can be used to create a detailed billing report for a company that provides tax consultations for customers:
The information will be in the provided data file customers.txt. The data file consists of several rows of data, as follows (commas are not in the file):
Customer First Initial, Customer Last Name, Customer ID, Yearly Income, Consulting Time in Minutes, Consulting Agent ID
Request the name of the input file from the user. Do not hard-code the file name in the program.
Read the file using a looping construct that checks for the end of file (not the number of rows in the data file).
The agent ID maps to an agent last name and hourly rate. Evaluate the agent ID using a SWITCH statement to retrieve the agent last name and hourly rate. The mapping values are as follows. You will use these as constants/literals in your program:
Agent ID 1 = Bortles; Hourly Rate = 65.00
Agent ID 2 = Cower; Hourly Rate = 70.00
Agent ID 3 = Watt; Hourly Rate = 75.00
Any other agent ID is an error and needs to be handled accordingly. See Error Handling below.
Determine if the customer is a low income customer and set a flag accordingly (Y or N). This is to be output in the report (see below) and may be used for calculating the customers amount due (bill). A customer is low income if the yearly income is less than or equal to $25,000.
Calculate the customers amount due (bill) as follows:
If the customer is a low income customer:
If the consulting time is less than or equal to 30 minutes, the amount due (bill) is 0.00
If the consulting time is greater than 30 minutes, the amount due (bill) is 40% of the hourly rate (billing rate) times (the consulting time minus 30 minutes) divided by 60 minutes (i.e., billed by the hour). For example, if the consulting time is 32 minutes the calculation would be:
Hourly rate * 0.40 * (32 - 30) / 60
Otherwise (the customer is not a low income customer):
If the consulting time is less than or equal to 20 minutes, the amount due (bill) is 0.00
If the consulting time is greater than 20 minutes, the amount due is 70% of the hourly rate (billing rate) times (the consulting time minus 20 minutes) divided by 60 minutes.
Request an output file name from the user. Do not hard-code the file name in the program.
For each error-free row of input in the data file, output the following to the console (screen) in a neat, readable format. Output each input line on one output line. Use manipulators to output values in readable columns. Use dollar signs before monetary values. All monetary values must have 2 decimal points. Use headings to indicate values displayed (you DO NOT need to use the headings below, you may use your own):
Customer Name (initial and last name)
Customer ID
Yearly Income
Consulting time (in minutes)
Amount Due (customers bill)
Low Income (Y or N indicator)
Agent Name (consulting agent)
Agents Hourly Rate
Output must be in the following form, i.e., a report header and one heading for all lines for output:
Billing Report
Customer Name Customer ID Yearly Income Consulting Time Amount Due Low Income Agent Name Rate
For each error-free row of input in the data file, output the following to an output file, name of your choice, entered as requested, (in addition to the console) in a neat, readable format. Output each input line on one output line. Use manipulators to output values in readable columns. Use dollar signs before monetary values. All monetary values must have 2 decimal points. Use headings to indicate values (you DO NOT need to use the headings below, you may use your own):
Customer Name (initial and last name)
Customer ID
Yearly Income
Consulting time (in minutes)
Amount Due (customers bill)
Low Income (Y or N indicator)
Agent Name (consulting agent)
Agents Hourly Rate
Output must be in the following form, i.e., a report header and one heading for all lines for output:
Billing Report
Customer Name Customer ID Yearly Income Consulting Time Amount Due Low Income Agent Name Rate
You MAY use abbreviations for headers to fit across the screen.
Error Handling: There will be errors in the data file (see below for possible errors). If an error in the data is encountered, write the nature of the error and the customer name (initial and last name) and customer id containing the error to a second output file, name of your choice (not the console). Do Not Process the Data; continue with the next input line. Only log the first error found in each line/row of data.
You MAY hardcode (use a literal/constant) the name of the output error file.
Possible errors:
Valid agent IDs are 1, 2 and 3. Any other agent ID is an error.
The yearly income and consulting minutes must be greater than zero. Check both the yearly income and consulting minutes in your program.
Open all necessary data files and check the state of all file opens. If any file does not open properly, display an appropriate message and exit the program.
CLOSE ALL files before exiting the program.
customers.txt
J Jones 33567 25000.00 30 1 R Grover 87 250000.00 120 3 B Roebuck 7 300000.01 90 3 J Hancock 1212 0 20 1 D Vaughan 12234 100000.00 60 3 E Blackwell 1821 32000.00 45 2 O Knowles 3456 50000.00 35 5 J Anderson 1998 18000.00 19 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
