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

Hi I really need help with this problem ASAP, so any and all advice is welcomed!

ID: 3717316 • Letter: H

Question

Hi I really need help with this problem ASAP, so any and all advice is welcomed! If possible can one also provide the coupling diagram and flowchart for this aswell, Thanks!

Design an algorithm and then write a C++ program for the algorithm that determines the cost of
using a cell phone service for a customer. This provider calculates the monthly cost of the service as
follows. Note: Minutes, texts, and data are the overall amount used by everyone on the account, the
data is in the file of Customers.txt. The charge for calls, texts, data, and line on an account will be
calculated as follows:
– Calls: Up to 100 minutes is $3, up to 1000 minutes is $25
• If over 1000, the calls are 2 cents per minute
– Texts: Up to 100 texts is $1, up to 1000 texts is $5
• If over 1000, texts are 0.25 cents per message (4 texts = 1 cent)
– Data: Up to 1 gigabyte is $20, up to 2 gigabytes is $30
• If over 2 gigabytes, data is $10 per gigabyte
– Each line on the account is $6
Your program will open a file called Customers.txt. This file will have one line per customer record.
The record will list the number of lines, the number of minutes, the number of texts, and the number
of gigabytes of data used. The program will use the following functions:
1. double calculateCost() is passed the number of lines, the number of calls, the number of texts,
and the amount of gigabytes of data used. It should be called once for each customer. This function
will call other functions. It will return the cost for the customer.
2. double getCallCost() is passed the number of minutes used and calculates the cost based on the
prices listed above. This function is called by the calculateCost() function. It returns a double
representing the how much the customer should be charged for the number of minutes used.
3. double getTextCost() is passed the number of messages sent and calculates the cost based on
the prices listed above. This function is called by the calculateCost() function. It returns a double
representing the how much the customer should be charged for the number of messages sent.
4. double getDataCost() is passed the number of gigabytes used and calculates the cost based
on the prices listed above. This function is called by the calculateCost() function. It returns a
double representing the how much the customer should be charged for the number of gigabytes
used.

Explanation / Answer

#include<bits/stdc++.h>

using namespace std;

double getCallCost(int minutes)

{

if(minutes<=100)return 3.0;

if(minutes<=1000)return 25.0;

else

{

return (2.0*minutes)/100.0;

}

}

double getTextCost(int texts)

{

if(texts<=100)return 1.0;

if(texts<=1000)return 5.0;

else

{

return (0.25*texts)/100.0;

}

}

double getDataCost(int data)

{

if(data<=1)return 20.0;

if(data<=2)return 30.0;

else

{

return 10.0*data;

}

}

double calculateCost(int line,int minutes,int texts,int data)

{

double cost=getDataCost(data) + getCallCost(minutes) + getTextCost(texts) + line*6.0;

return cost;

}

int main()

{

char ch;

int line,texts,minutes,data;

ifstream fin;

fin.open("Customers.txt");

while(!fin.eof())

{

fin>>line>>minutes>>texts>>data;

cout<<"COST : "<<calculateCost(line,minutes,texts,data)<<" ";

}

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote