Answer to Question #295169 in C++ for sadwe

Question #295169

You will create a program that displays amount of a cable bill. The Amount is based on the type of customer, as shown in the figure. For a residential customer, the user will need to enter the number of premium channels only. For a business customer, the user will need to enter the number of connections and the number of premium channels. Also enter appropraite comments and any additional instructions in your c++ program. Test the program appropriately before submission. 


For resedential customers:

Processing fee: $4.50

Basic service fee: $30

Premium channels: $5 per channel


For business customers:

Processing fee: $16.50

Basic service fee: $80 for the first 5 connections, $4 for each additional connection

Premium channels: $50 per channel for any number of connections




1
Expert's answer
2022-02-08T11:42:27-0500
#include <iostream>
#include <iomanip>
using namespace std;


// Define some constants
const double RES_PROCESSING_FEE = 4.50;
const double RES_BASIC_SERVICE_FEE = 30;
const double RES_PREMIUM_CHANNELS = 5;
const double BUS_PROCESSING_FEE = 16.5;
const double BUS_BASIC_SERVICE_FEE_FIST = 80;
const int    NUM_FIRST_CONNECTIONS = 5;
const double BUS_BASIC_SERVICE_FEE_ADD = 4;
const double BUS_PREMIUM_CHANNELS = 50;


int main() {
    int cust_type = 0;


    cout << "Enter a type of the customer: 1 - resedential, 2 - bussness ";
    cin >> cust_type;
    while (cust_type != 1 && cust_type != 2 ) {
        cout << "Incorrect input" << endl;
        cout << "Enter 1 - resedential, 2 - bussness ";
        cin >> cust_type;
    }


    double bill;


    if (cust_type == 1) {
        int num_channels;
        cout << "Enter a number of premium channels: ";
        cin >> num_channels;
        if (num_channels < 0)
            num_channels = 0;


        bill = RES_PROCESSING_FEE + RES_BASIC_SERVICE_FEE;
        bill += num_channels * RES_PREMIUM_CHANNELS;
    }
    else {
        int num_connections, num_channels;


        cout << "Enter a number of connections: ";
        cin >> num_connections;
        if (num_connections < 0) 
            num_connections = 0;


        cout << "Enter a number of premium channels: ";
        cin >> num_channels;
        if (num_channels < 0)
            num_channels = 0;


        bill = BUS_PROCESSING_FEE;
        bill += BUS_BASIC_SERVICE_FEE_FIST;
        if (num_connections > NUM_FIRST_CONNECTIONS) 
            bill += (num_connections - NUM_FIRST_CONNECTIONS) * BUS_BASIC_SERVICE_FEE_ADD;
        bill += num_channels * BUS_PREMIUM_CHANNELS;
    }

    cout << "Your bill is $" << fixed << setprecision(2) << bill << endl;

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog