Answer to Question #306258 in C++ for sanza

Question #306258

Write a program that computes the cost of a long distance call. The cost of call is determined according to the following rate schedules.

• A call made between 8:00 AM and 6:00 PM is billed at a rate of 6 rupees per minute.

• A call made before 8:00 AM or after 6:00 PM is charged at a rate of 3.75 rupees.

According to this schedule, if a call starts at any time between 8:00 AM and 6:00 PM, and it ends after 6:00 PM then it will be charged at the rate of 6 rupees per minute for the time before 6:00 PM and for the rest of the time rate will be 3.75 rupees per minute. For example if a call starts at 5:55 PM and ends at 6:05 PM then charges on this call will be 48.75 (30 rupees for first 5 minutes and 18.75 rupees for rest of the time).

Similarly if call starts at the time before 8:00 AM but ends after 8:00 AM then it will be charged at rate of 3.75 rupees for the time before 8:00 AM and for remaining minutes after 8:00 AM the rate will be 6 rupees per minute.



1
Expert's answer
2022-03-05T04:11:52-0500
#include <iostream>

int main() {
    int callTime, minutes;
    std::cout << "Please input 1 if is between 8:00 AM and 6:00 PM now, or 0 otherwise" << std::endl;
    std::cin >> callTime;
    std::cout << "Please input number of minues you want to talk" << std::endl;
    std::cin >> minutes;
    if (callTime) {
        std::cout << "You call is worth " << (double) minutes * 6 << " rupees" << std::endl;
    } else {
        std::cout << "You call is worth " << (double) minutes * 3.75 << " rupees" << std::endl;
    }
    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

LATEST TUTORIALS
New on Blog