Question

Write a C++ program to determine the cost of cell phone bill.

Write a C++ program to determine the cost of cell phone bill.
media%2F6b2%2F6b2fcebe-f4d7-46f3-a3c8-10
media%2F868%2F86858327-60a3-49c3-b762-75
0 0
Add a comment Improve this question Transcribed image text
Answer #1

NOTE: I have completed the program for your assignment. Please check and let me know if you have any questions. I will acknowledge back with a response within 24 hours. Thanks for your patience.

The file CustomersA.txt you have given is a screenshot and i was not able to copy the contents. So i have picked the first three lines as a sample and tested the program. You create the original CustomersA.txt file and test the program.

Code:

#include <iostream>

#include <fstream>

using namespace std;

// function declaration

double calculateCost(int, int, int, int);

int main()

{

// file and variable declaration

ifstream infile("CustomersA.txt");

int lines, mins, texts, gb;

double cost;

// reading each line from file

if (infile.is_open()){

while(infile >> lines >> mins >> texts >> gb){

// passing the attributes to calculateCost to determine the total cost customer has to pay

cost = calculateCost(lines, mins, texts, gb);

cout << "Customer has to pay: " << cost << endl;

}

}

else

cout << "Some issue while file opening, plese check..." << endl;

cout << endl;

return 0;

}

double calculateCost(int lines, int mins, int texts, int gb)

{

double total_cost;

total_cost = 6 * lines; // line cost

total_cost += 0.02 * mins; // calls

total_cost += 0.25 * texts; // message cost

total_cost += 10 * gb; // Data cost

return total_cost;

}

Codee output screenshot:

sh-4.4$ cat CustomersA.txt 1 1362 1134 1 3 815 495 4 1 1137 606 3 sh-4.4$ g++ prog.cpp sh-4.4$ ./a.out Customer has to pay: 3

Add a comment
Know the answer?
Add Answer to:
Write a C++ program to determine the cost of cell phone bill.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • EXERCISE Cell Phone Bill The total cost for your bill is sum of the base plan...

    EXERCISE Cell Phone Bill The total cost for your bill is sum of the base plan and the additional cost for extra minutes and texts The charges are: Base plan: $40.00 Additional Minutes: $2.61 Additional Texts: $3.15 Additional Data: $12.20 Enter your value as a decimal number, dollar and cents. For example, enter $13.45 as 13.45 West (4 of 4) Check 10 item attempts remaining Try Another Version Submit Answer

  • Q2.1) Write a program to calculate phone bill of the user. The rule to calculate bill...

    Q2.1) Write a program to calculate phone bill of the user. The rule to calculate bill is given as follows: • You should ask the option to the user at first. If the phone bill will be calculated with internet connection option, user must enter 1, otherwise user must enter O. Do all necessary controls and take the number from the user until the user enters one of the correct options. (1 or 0). • Design 2 different methods. Both...

  • Write the pseudocode to produce a bill for cell phone charges. Data fields will include the date, number called, number of minutes, and cost (rate × minutes). Data should be loaded into an array. Include totals for the number of minutes and cost.

    Write the pseudocode to produce a bill for cell phone charges. Data fields will include the date, number called, number of minutes, and cost (rate × minutes). Data should be loaded into an array. Include totals for the number of minutes and cost.

  • According to one study, the average monthly cell phone bill in the U.S. is $70

    According to one study, the average monthly cell phone bill in the U.S. is $70. If a 20-year old student with an average bill gives up her cell phone and each month invests the $70 she would have spent on her phone bill in a savings plan that averages a 4% annual return, how much will she have saved by the time she is 65?

  • Lab 8 python code for Cell Phone Bill

    Lab 8: Cell Phone Bill CalculatorWrite the Python code for the following programming problem definition.Use modular design according to the modules specified below.Design and write a program that calculates and displays the number of minutes over the monthly contract minutes that a cell phone user incurred. The program should askthe user how many minutes were used during the month and how many minutes they were allowed. Validate the input as follows:• The minimum minutes allowed should be at least 100,...

  • The average single smart phone cell phone bill is now averaging $73 with a standard deviation...

    The average single smart phone cell phone bill is now averaging $73 with a standard deviation of $20. What is the probability that a sample mean of 40 produces a sample mean equal to $73?

  • The average single smart phone cell phone bill is now averaging $73 with a standard deviation...

    The average single smart phone cell phone bill is now averaging $73 with a standard deviation of $20. What is the probability that a sample mean of 40 produces a sample mean between $70 and $80?

  • 64. Write a function d G) that represents the sale price of a cell phone after...

    64. Write a function d G) that represents the sale price of a cell phone after applying only the 25% off discount where x represents the original price of the cell phone B. Write a function c(x)that represents the cost of a cell phone after applying only the $150 off coupon where x represents the original price of the cell phone. C. Write a new function f(x) = d(c(x)) and explain in words what this means in the context of...

  • Write a complete C++ program that creates a monthly bill for the text messaging. Your cell...

    Write a complete C++ program that creates a monthly bill for the text messaging. Your cell phone company provides the following three text messaging plans. Package A: Two Thumbs.   For $9.95 per month, 100 text messages are allowed. Additional text messages are 15 cents each. Package B: All Thumbs. For $14.95 per month, 200 text messages are allowed. Additional text messages are 10 cents each. Package C: Lightning Thumbs. For $19.95 per month, unlimited text messaging is provided. State sales...

  • The average monthly cell phone bill was reported to be $73.00 by the U.S. Wireless Industry....

    The average monthly cell phone bill was reported to be $73.00 by the U.S. Wireless Industry. A random sampling of ten large cell phone company found the following monthly cell phone charges yields a sample mean of $78.47 with a population standard deviation of $7.41. At the 0.05 level of significance, can it be concluded that the average monthly cell phone bill differs from $73.00? Question 24 (2.63 points) Which test are you running? One mean z-test Chi-Square Goodness of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT