Skip to content

Cell Phone Company Program #20

@IMACULGY

Description

@IMACULGY

Please refer to the program below, detailing a cell phone company and its services:

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
  char service;
  int accnum;
  double cost;

  cout << "Enter account number: ";
  cin >> accnum;
  cout << "Enter 'r' for regular service or 'p' for premium service: ";
  cin >> service;
  cout << fixed << showpoint << setprecision(2);

  if (service == 'r' || service == 'R')
  {
    int minutes;

    cout << "Enter the number of minutes used: ";
    cin >> minutes;

    if (minutes <= 50)
      minutes = 0;
    else
      minutes -= 50;
    
    cost = 10 + minutes * 0.20;

    cout << "Cost: $" << cost;
  }
  else if (service == 'p' || service == 'P')
  {
    int minDay, minNight;
    double costDay, costNight;

    cout << "Enter the number of minutes used at day and at night (separated by spaces): ";
    cin >> minDay >> minNight;

    if (minDay <= 75)
      minDay = 0;
    else
      minDay -= 75;
    costDay = 0.10 * minDay;

    if (minNight <= 100)
      minNight = 0;
    else
      minNight -= 100;
    costNight = 0.05 * minNight  ;

    cost = 10 + costDay + costNight;

    cout << "Cost: $" << cost;


  }
  else
    cout << "Incorrect input. Try again later.";


  return 0;
}

The two types of services this company officers are regular and premium, as shown above.
Its rates vary, depending on the type of service. The rates are computed as
follows:

Regular service: $10.00 plus first 50 minutes are free. Charges for
over 50 minutes are $0.20 per minute.

Premium service: $25.00 plus:
a. For calls made from 6:00 a.m. to 6:00 p.m., the first 75 minutes are free;
charges for more than 75 minutes are $0.10 per minute.
b. For calls made from 6:00 p.m. to 6:00 a.m., the first 100 minutes are
free; charges for more than 100 minutes are $0.05 per minute.

Rewrite the program so that it uses the following functions to calculate the billing
amount. Do NOT output the number of minutes during which the service is used.
a. regularBill: This function calculates and returns the billing amount
for regular service.
b. premiumBill: This function calculates and returns the billing amount
for premium service.

You may name the program as you please, for example, "CellPhoneCompany.cpp"

Please make sure the program compiles and runs as it should!

CONTRIBUTING.md

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions