.. 11 AT&T; LTE 09:29 a learn.vccs.edu Programming Assignment 2 File IO Control
ID: 3906251 • Letter: #
Question
.. 11 AT&T; LTE 09:29 a learn.vccs.edu Programming Assignment 2 File IO Control structures Looping Operator precedence Error checking (bad data, file stream fail state, etc.) Use of proper data types Exact output Write a program that can be used to create a detailed billing report for a company that provides tax consultations for customers: 1. 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 2. Request the name of the input file from the user. Do not 3. Read the file using a looping construct that checks for the 4. The agent ID maps to an agent last name and hourly rate hard-code" the file name in the program. end of file (not the number of rows in the data file). 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 5. 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 customer's amount due ( A customer is low income if the yearly income is less than or equal to $25,000 6. Calculate the customer's 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 rate0.40 (32- 30) 60Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
ifstream inData;
ofstream outData;
string fileName;
cout << "Enter the data file Name : " << endl;
cin >> fileName;
inData.open(fileName.c_str());
while(scanf("%d" , &n) != EOF) {
switch(agent_id)
{
case 1:
last_name = "Bortles";
hourly_rate = 65.00;
break;
case 2:
last_name="Cower";
hourly_rate=70.00;
break;
case 3:
last_name="Watt";
hourly_rate=75.00;
break;
default:
}
if(yearly_income<=25000)
{
flag="Y";
}
else
flag="N";
if(flag=="Y"){
if(consuming_time<=30)
{
amt_due=0.00;
}
else if(consuming_time>30)
{
amt_due=(hourly_rate*0.40*(consuming_time-30)/60);
}
}
else{
if(consuming_time<=20)
amt_due=0.00;
else
amt_due=(hourly_rate*0.70*(consuming_time-20)/60);
}
}
outData.open(fileName.c_str());
cout << fileName;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.