Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

IN C++ CODING You will implement a program called \"call stats4.cpp\" to process

ID: 3596430 • 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: 1. 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. 2. The function "Process will have two parameters: call_DB and count. The function "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)

Explanation / Answer

#include<iostream>
#include<fstream>
#include <stdlib.h>
#include <string>
#include<iomanip>
using namespace std;

int SIZE=200;
struct callRecord
{
string cell_number;
int relays;
int call_length;
double tax_rate;
double net_cost;
double call_tax;
double total_cost;

};
void Input(callRecord call_DB[],int& c)
{

ifstream myfile;
myfile.open("call_data.txt");
while(!myfile.eof())
{

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;


cout<<call_DB[i].relays;
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;
}

}
int main()
{
callRecord call_DB[SIZE];
int count=0;
Input(call_DB,count);
Process(call_DB,count);
Output(call_DB,count);
return 0;

}

Please do upvote this answer.