c++ programming ECNG 1009 introduction to Programming In Course Exam 1 2016/17 S
ID: 3733335 • Letter: C
Question
c++ programming
ECNG 1009 introduction to Programming In Course Exam 1 2016/17 Supplemental Sheet mobile telecommunications provider in the Caribbean has hired you as a Scenario: The technical team of a leading consultant. They would ike to assess the current post-paid and pre-pald packapes devised by their marketing team. It s in the technical teans opinion that the post-paid and pre-paid packages should be based on KPI's (key performance ndicators) based on customer usage patterns and not at the whim of the marketing team. The technical team gives you access to raw customer usage data in the form of .text fle hthe format shown below. " is your job to perform analysis on this data and generate an automatie summary of the processed KPI's (key performance indicators) as shown in the image of the CustomerUsageSummary.tt file below File Est Format Viw Help CustoserID 9812345 9812346 9812347 9812348 9812349 9812358 9812351 9812352 9812353 9812354 812355 64,4 PostPd PostPd 23 42 238.4 61.6 22.4 274.4 184.8 67.2 192 281.6 PostPd 65 72 File Edit Format View Help Custoner Usage Sumnary for January 2817 Call Frequency Statistics Post Paid Average Number of Calls, Po c:26.6 Pre Paid Average Nusber of Calls, Pr c:61.1111 Call Duration Statisties Post Paid Average Call Duration, Po_d:2.24 Pre Paid Average Call Duration, Pr d:2.48889 Frequency-Duration Index, FOI Post Paid FDI:1555 Pre Paid FDI:27898 4. In an attempt to code the solution (belaw) resulted in some errors. Identify the errors and re-write the corrected code. [6 marks] bsol SP astPd(stdestrinc); et fdi int, int) int sain) f1aat nca110rn(float, int, float); float av Mukalls(float, int, float); int11e.open(Web lecustomerOata.txt.); while (!infle.good()) { infile id; infile pp: infile nums:infile ins else (prcountw pr_d avallbrn): pre avuCals return 8;Explanation / Answer
//If you find this helpful, then please leave a like. I have included comments to all the corrections I've made.
bool isPostPd(std::string); float avCallDrn(float,int,float); float avNumCalls(float, int, float);
int fdi(int, int);
int main()
{
std::ifstream inFile; //Proper declaration
inFile.open("MobileCustomerData.txt");
int id,nums,pocount,prcount,Count; //Declaring all variables.
float mins,po_c,po_d,pr_c,pr_d;
std::string pp;
Count=0; //Initializing all counting variables to 0.
prcount=0;
pocount=0;
po_c=0; //Initializing all averages to 0.
po_d=0;
pr_c=0;
pr_d=0;
while (inFile.good()) //not !inFile.good() as good() returns true when there is no error
{
inFile >> id;
inFile >> pp;
inFile >> nums;
inFile >> mins;
if(Count>1) // To avoid using the first line, which has the column headings
{
if (isPostPd(pp)) //Need to provide the string pp
{
pocount++;
po_d=avCallDrn(po_d,pocount,mins); // With these parameters we can calculate the new average.
po_c=avNumCalls(po_c,pocount,nums);
}
else
{
prcount++;
pr_d=avCallDrn(pr_d,prcount,mins);
pr_c=avNumCalls(pr_c,prcount,nums);
}
}
Count++;
}
int pr_fdi = fdi(pr_c, pr_d);
int pd_fdi = fdi(po_c, po_d);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.