Question

In: Computer Science

Program Requirements: An Internet service provider has three different subscription packages for its customers: Package A:...


Program Requirements:

An Internet service provider has three different subscription
packages for its customers:

Package A: For $15 per month with 50 hours of access provided.
Additional hours are $2.00 per hour over 50 hours.
Assume usage is recorded in one-hour increments,

Package B: For $20 per month with 100 hours of access provided.
Additional hours are $1.50 per hour over 100 hours.

Package C: For $25 per month with 150 hours access is provided.
Additional hours are $1.00 per hour over 150 hours

Write a program that calculates a customer’s monthly charges.
Implement with the following functions for your solution.
getPackage
validPackage
getHours
validHours
calculatePkg_A
calculatePkg_B
calculatePkg_C
calculateCharges
showBill

----------------------------------------------
Demonstrate test cases as described in table:
---------------------------------------------- 
Test Case      Package           Hours
         1                   A                    50
         2                    a                    51
         3                    B                 100 
        4                     b                 101
        5                    C                  149
       6                      c                   151
       7                      e                  720
       8                      c                  722

Solutions

Expert Solution

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

#include <iostream>
#include <iomanip>

using namespace std;

char getPackage();
bool validPackage(char ch);
int getHours();
bool validHours(int hrs);
double calculatePkg_A(int hours);
double calculatePkg_B(int hours);
double calculatePkg_C(int hours);
void showBill(char pack,int hours,double cost);
int main() {
  
char pack;
int hours;
double cost=0;
pack=getPackage();
hours=getHours();
if(pack=='A' || pack=='a')
{
   cost=calculatePkg_A(hours);
   }
   else if(pack=='B' || pack=='b')
{
   cost=calculatePkg_B(hours);
   }
   if(pack=='C' || pack=='c')
{
   cost=calculatePkg_C(hours);
   }
   showBill(pack,hours,cost);

return 0;
}
char getPackage()
{
   char ch;
   while(true)
   {
   cout<<"Enter package :";
   cin>>ch;
   if(validPackage(ch))  
   break;
   }
return ch;
  
}
bool validPackage(char ch)
{
   if(ch=='A' || ch=='a' || ch=='B' || ch=='b' || ch=='C' || ch=='c')
   return true;
   else
   {
       cout<<"** Invalid.Package must be either A, B or C **"<<endl;
   return false;  
   }
  
}
int getHours()
{
   int hrs;
   while(true)
   {
   cout<<"Enter hours :";
   cin>>hrs;
   if(validHours(hrs))
   break;
          
   }
   return hrs;

}
bool validHours(int hrs)
{
   if(hrs<=0)
   {
       cout<<"** Invalid.Must be > 0 **"<<endl;
       return false;
   }
   else
   {
       return true;
   }
}
double calculatePkg_A(int hours)
{
   double cost=0;
   if(hours<=50)
   {
       cost=15;
   }
   else
   {
       cost=15+2*(hours-50);
   }
   return cost;
}
double calculatePkg_B(int hours)
{
       double cost=0;
   if(hours<=100)
   {
       cost=20;
   }
   else
   {
       cost=20+1.5*(hours-100);
   }
   return cost;
}
double calculatePkg_C(int hours)
{
       double cost=0;
   if(hours<=150)
   {
       cost=25;
   }
   else
   {
       cost=25+1*(hours-150);
   }
   return cost;
}
void showBill(char pack,int hours,double cost)
{
   //setting the precision to two decimal places
   std::cout << std::setprecision(2) << std::fixed;

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

_________________________

Output:

_______________________

________________________

_______________________

________________________

________________________

_______________Could you plz rate me well.Thank You


Related Solutions

An Internet service provider has three different subscription packages for its customers: Package A: $9.95 per...
An Internet service provider has three different subscription packages for its customers: Package A: $9.95 per month 10 hours of access are provided.   Additional hours are $2.00 per hour. Package B: $14.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour. Package C: $19.95 per month unlimited access is provided. Write a MATLAB script to calculates a customer’s monthly bill. It should ask which package the customer has purchased and how many hours were used....
A mobile phone service provider has three different subscription packages for its customers: Package A: For...
A mobile phone service provider has three different subscription packages for its customers: Package A: For $39.99 per month 450 minutes are provided. Additional minutes are $0.45 per minute. Package B: For $59.99 per month 900 minutes are provided. Additional minutes are $0.40 per minute. Package C: For $69.99 per month unlimited minutes provided. Write a program that calculates a customer’s monthly bill. It should ask which package the customer has purchased and how many minutes were used. It should...
Internet Service provider Part 1 (Java Program) An Internet service provider has three different subscription packages...
Internet Service provider Part 1 (Java Program) An Internet service provider has three different subscription packages for its customers: Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour. Package B: For $13.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour. Package C: For $19.95 per month unlimited access is provided. Write a program that calculates a customer’s monthly bill. It should ask the user to...
**PYTHON** A new movie theatre has three different subscription packages for its customers: Package A: For...
**PYTHON** A new movie theatre has three different subscription packages for its customers: Package A: For $18.95 per month, the customer can watch 2 movies. Any additional movie requires an additional $2 per movie. Package B: For $22.95 per month, the customer can watch 4 movies. Any additional movie requires an additional $1 per movie. Package C: For $30.99 per month, the customer can watch an unlimited amount of movie. Write a script that calculates a customer’s monthly bill. It...
CPSC 1103 Assignment 1 Problem A cell phone provider has three different subscription packages for its...
CPSC 1103 Assignment 1 Problem A cell phone provider has three different subscription packages for its customers: Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour. Package B: For $14.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour. Package C: For $19.95 per unlimited access is provided. Write a program to ask which package the customer has purchased, what month they are using, and how...
wirte a program in java Part I     Internet Service Provider An Internet service provider has three...
wirte a program in java Part I     Internet Service Provider An Internet service provider has three different subscription packages for its customers: Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour. Package B: For $13.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour. Package C: For $19.95 per month unlimited access is provided. Write a program that calculates a customer’s monthly bill. It should ask...
Internet service: An Internet service provider sampled 530 customers, and finds that 70 of them experienced...
Internet service: An Internet service provider sampled 530 customers, and finds that 70 of them experienced an interruption in high-speed service during the previous month. (b) Construct a 90% confidence interval for the proportion of all customers who experienced an interruption. Round the answers to at least three decimal places.
Internet service: An Internet service provider sampled 545 customers, and finds that 65 of them experienced...
Internet service: An Internet service provider sampled 545 customers, and finds that 65 of them experienced an interruption in high-speed service during the previous month. (b) Construct a 99.8% confidence interval for the proportion of all customers who experienced an interruption. Round the answers to at least three decimal places. A 99.8% confidence interval for the proportion of all customers who experienced an interruption is _<p<_.
Amazon has three packages (Package A, Package B, and Package C) that is to be shipped...
Amazon has three packages (Package A, Package B, and Package C) that is to be shipped to Bill’s address. Package A is worth $100, Package B is worth $200, and Package C is worth $300. All three packages have a 90% chance of arriving and a 10% chance of being lost in transit. a. Set up a probability distribution with the appropriate probabilities for each possible outcome. b. What is the expected loss (P*)? c. How much risk does Amazon...
A TV satellite provider charges $42 a month for its basic service package. Its variable costs...
A TV satellite provider charges $42 a month for its basic service package. Its variable costs are $4 a month per account. The company spends $24 a year per account on marketing with an attrition rate of 1% a month. Assuming an annual discount rate of 5%, calculate the maximum amount that this company could spend to acquire a new customer and still provide a positive expected contribution. Please show the work as I’m trying to learn the concept
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT