c++ programming ECNG 1009 Introduction to Programming In Course Exam 1 2016/17 S
ID: 3733321 • Letter: C
Question
c++ programming
ECNG 1009 Introduction to Programming In Course Exam 1 2016/17 Supplemental Sheet Scenarlioc The technical team of a leading mobile telecommunications provider in the Caribbean has hired you as a consultant. They would like to assess the current post-paid and pre-paid packages devised by their marketing team It is in the technical team's opinion that the post paid and pre-paid packages should be based on KPt's ey performance indicators) based on customer usage pattens and not at the whim of the marketing team. The technical team gives you access to raw customer usage data in the form of a text file in the format shown below, It is your job to perform analysis on this data and generate an automatic summary of the processed KPI's (key performance indicators) as shown in the image of the "CustomerUsageSummary.bt" file below. Fle Ede Fermat View Help CustonerID 9812345 9812346 9812347 9812348 9812349 64.4 PostPd 42 100 103 288.4 61.6 22.4 274.4 184.8 67.2 PostPd 9812351 9812352 9812353 9812354 9812355 98 24 65 72 201.6 File Edt Fomat ew Hep Custoser Usage Sunsary for January 2017 Call Frequency Statistics Post Paid Average usber of Calls, Po_c:26.6 Pre Paid Average umber of Calls, Pr c:61.1111 Call Duration Statistics Post Paid Average Call Duration, Po d:2.24 Pre Paid Average Call Duration, Pr d:2.48889 tion Index, FDI Post Paid FOI:1555 PrePaid FDI:27898 ECNG 1009 Introduction to Programming In Course Exam 1 2016/17 Duratlon: 1 hour 45 mins Answer All Questions-46 marks Time: 10:15am-12noon Please read the scenario provided in the supplemental sheet before attempting Questions 1 to 6. If a function is already written for one question, there is no need to rewrite it for other questions. 1. After much deliberation you were able to establish an algorithm to read in the raw data values and process the relevant KPI's. Develop a high level flow diagram for the process below only. ll open file If read values one at a time Il for each entry: distingulsh between packages (function call // for each aekaen: Cakulate the averam number of ealls llierterala [6 marks]Explanation / Answer
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream infile("MobileCustomerData.txt");
if(!infile) {
cout << "Cannot open input file. ";
return 1;
}
string line;
getline(infile, line); //First line which has column names, this will be skipped coz while loop will start from 2nd line
float prefr,postfr,predur,postdur,prefdi,postfdi,sumPrefr,sumPostfr,sumPredur,sumPostdur,sumdur,sumfr;
int numPre=0,numPost=0;
cout<<"Customer Usage Summary"<<endl;
while (getline(infile, line)){
istringstream iss(line); // read line into string stream
long custID;
string plan;
int numCalls;
float minUsed;
if (!(iss >> custID >> plan >> numCalls >> minUsed)) { break; } // Error reading steam
else {
if(plan.comapre("PostPd") == 0){
numPost++;
sumPostfr += numCalls;
sumPostdur += minUsed;
} else {
numPre++;
sumPrefr += numCalls;
sumPredur += minUsed;
}
}
}
prefr = sumPrefr/numPre;
postfr = sumPostfr/numPost;
predur = sumPredur/numPre;
postdur = sumPostdur/numPost;
prefdi = prefr*predur;
postfdi = postfr*postdur;
cout<<"Call Frequency Statistics"<<endl;
cout<<"Post-Paid Average number of calls, Po_c:"<<postfr<<endl;
cout<<"Pre-Paid Average number of calls, Pr_c:"<<prefr<<endl;
cout<<"Call Duration Statistics"<<endl;
cout<<"Post-Paid Average Call Duration, Po_d:"<<postdur<<endl;
cout<<"Pre-Paid Average Call Duration, Pr_d:"<<predur<<endl;
cout<<"Frequency-Duration Statistics"<<endl;
cout<<"Post-Paid FDI:"<<postfdi<<endl;
cout<<"Pre-Paid FDI"<<prefdi<<endl;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.