Answer to Question #312223 in C++ for Izen

Question #312223

A New Telephone Company has the following rate structure for long distance calls:

● The regular rate for a call is $0.10 per minute. (10 marks)

● Any call started at or after 6:00P.M. (1800 hours) but before 8:00A.M. (0800 hours) is

discounted 50 percent.

● Any call longer than 60 minutes receives a 15 percent discount on its cost (after any other

discount is subtracted).

● All calls are subject to a 4 percent federal tax on their final cost.

without using loops or functions


1
Expert's answer
2022-03-15T16:46:10-0400
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
    int t, hr, min;
    int start, end;

    cout << "Enter time of a call start (military format): ";
    cin >> t;

    hr = t / 100;
    min = t % 100;
    start = hr*60 + min;


    cout << "Enter time of a call end (military format): ";
    cin >> t;

    hr = t / 100;
    min = t % 100;
    end = hr*60 + min;

    int duration = end - start;
    if (duration < 0) {
        duration += 24*60;
    }

    double cost;
    cost = duration * 0.1;

    // Night call discount
    if (start < 8*60 || start >= 18*60) {
        cost *= 0.5;
    }

    // Long call discount
    if (duration > 60) {
        cost *= 0.85;
    }

    cost *= 1.04;   // Federal tax

    cout << "Total cost is $" << fixed << setprecision(2) << cost;

    return 0;
}

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