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.
#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;
}
Comments
Leave a comment