Write a program that computes the cost of a long-distance call. The cost of the
ID: 3639024 • Letter: W
Question
Write a program that computes the cost of a long-distance call. The cost of the call isdetermined according to the following rate schedule:
a. Any call started between 7:00 A.M. and 9:00 P.M., Monday through Friday, is billed at a rate
of $0.30 per minute.
b. Any call started before 7:00 A.M. or after 9:00 P.M., Monday through Friday, is billed at a rate
of $0.15 per minute.
c. Any call started on a Saturday or Sunday is billed at a rate of $0.10 per minute.
The inputs will consist of (1) the day of the week, (2) the start/end time of the call, and (3) the
length of the call in minutes. The output will be the cost of the call. Input will come from the user
and outputs will be displayed via the console window.
Explanation / Answer
#include
using namespace std;
int main()
{
int start_time, minutes;
double cost;
char first, second, choice('Y');
do
{
cout<<"When did the call start? ";
cout<<"Please enter the time in 24-hour notation. ";
cin>>start_time;
cout<<"How long did the call last? ";
cin>>minutes;
cout<<"Please enter the first two letters of the day of the call. ";
cin>>first>>second;
if (((first=='M')||(first=='m'))&&((second=='O')||(second=='o')))
{
if ((start_time>=8)||(start_time<=18))
{
cost=minutes*.30;
}
else
{
cost=minutes*.15;
}
}
else if (((first=='T')||(first=='t'))&&((second=='U')||(second=='u')))
{
if ((start_time>=8)||(start_time<=18))
{
cost=minutes*.30;
}
else
{
cost=minutes*.15;
}
}
else if (((first=='W')||(first=='w'))&&((second=='E')||(second=='e')))
{
if ((start_time>=8)||(start_time<=18))
{
cost=minutes*.30;
}
else
{
cost=minutes*.15;
}
}
else if (((first=='T')||(first=='t'))&&((second=='H')||(second=='h')))
{
if ((start_time>=8)||(start_time<=18))
{
cost=minutes*.30;
}
else
{
cost=minutes*.15;
}
}
else if (((first=='F')||(first=='f'))&&((second=='R')||(second=='r')))
{
if ((start_time>=8)||(start_time<=18))
{
cost=minutes*.30;
}
else
{
cost=minutes*.15;
}
}
else if (((first=='S')||(first=='s'))&&((second=='A')||(second=='a')))
{
cost=minutes*.10;
}
else if (((first=='S')||(first=='s'))&&((second=='U')||(second=='u')))
{
cost=minutes*.10;
}
cout<<"The cost of the call is "< cout< cout<<"Do you want to rerun the program? Y or N ";
cin>>choice;
cout< }
while ((choice=='Y')||(choice=='y'));
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.