IN C++ CODING You will implement a program called \"call stats4.cpp\" to process
ID: 3596135 • Letter: I
Question
IN C++ CODING
You will implement a program called "call stats4.cpp" to process customer call records. You will read the records in a datafile into an array of call records, then process each call record in the array, and finally print the array of call records to a datafile. Remember, each customer call record contains seven fields, which are as follows: 1) a ten digit cell phone number (string, no dashes), 2) the number of relay stations used in making the call (integer), 3) the length of the call in minutes (integer), 4) the net cost of the call (double), 5) the tax rate (double), 6) the call tax (double) and 7) the total cost of the call (double). Your program will have 3 functions: Input, Process, and Output. Your main program will call each function once. Following are the descriptions of the functionality of each function: I. The void function “Input, will have two parameters: the call record array called "call_DB", and the count. call_DB, and count should be initialized in your main program. The global integer constant SIZE should be set to 200. count should be initialized to 0. The function will read the cell_number, relays, and call_length (in minutes) into the a call record in call_DB (call DB[i] is an individual call record) from the input data file. Remember, count should be passed by reference. The function "Process will have two parameters "Process" will calculate the net cost of a call (net cost), the tax on a call (call tax) and the total cost of the call (total cost) using the number of relay stations (relays) 2· : call DB and count. The functionExplanation / Answer
For using setprecision and fixed you will have to include <iomanip> before compiling.
void Input(callRecord call_DB[],int& c)
{
ifstream myfile;
myfile.open("call_data.txt");
while(!myfile.eof())
{
String a;
myfile>>call_DB[c].cell_number;
myfile>>call_DB[c].relays;
myfile>>call_DB[c].call_length;
c++;
}
}
void Process(callRecord call_DB[],int count)
{
int i;
for(i=0;i<count;i++)
{
if(call_DB[i].relays>=0 && call_DB[i].relays<=5 )
call_DB[i].tax_rate=0.01;
else if(call_DB[i].relays<=11 && call_DB[i].relays>=6)
call_DB[i].tax_rate=0.03;
else if(call_DB[i].relays>=12 && call_DB[i].relays<=20)
call_DB[i].tax_rate=0.05;
else if(call_DB[i].relays>=21 && call_DB[i].relays<=50)
call_DB[i].tax_rate=0.08;
else
call_DB[i].tax_rate=0.12;
call_DB[i].net_cost=(call_DB[i].relays/50.0)*0.40*call_DB[i].call_length;
call_DB[i].call_tax=call_DB[i].net_cost*call_DB[i].tax_rate;
call_DB[i].total_cost=call_DB[i].call_tax+call_DB[i].net_cost;
}
}
void Output(callRecord call_DB[],int count)
{
ofstream myfile;
myfile.open("weekly6_call_info.txt");
for(int i=0;i<count;i++)
{
myfile<<fixed<<setprecision(2)<<call_DB[i].cell_number<<" "<<call_DB[i].relays<<" "<<call_DB[i].call_length<<" "<<call_DB[i].net_cost<<" "<<call_DB[i].tax_rate<<" "<<call_DB[i].call_tax<<" "<<call_DB[i].total_cost<<endl;
}
}
Do give a thumbs up please.