Write a program that computes the cost of a long-distance call. The cost of the
ID: 3627476 • Letter: W
Question
Write a program that computes the cost of a long-distance call. The cost of the call is determined according to the following rate schedule:a. Any call started between 10:00 A.M. and 5:00 P.M., Monday through Friday, is billed at a rate of $0.30 per minute.
b. Any call started before 6:00 A.M. or after 10:00 P.M., Monday through Friday, is billed at a rate of $0.17 per minute.
c. Any call started on a Saturday or Sunday is billed at a rate of $0.30 per minute.
time is in military style.
these are the inputs:
Mo 15 30 15
Sa 10 00 30
Tu 2 30 45
Sq
Fr 20 01 60
Explanation / Answer
DEAR FRIEND
here is the full program u need
any questions message me
PLEASE RATE
#include <iostream>
#include <string>
#include<cctype>
using namespace std;
void calculate(string str, int arr[])
{
double rate;
str[0]=toupper(str[0]);
str[1]=toupper(str[1]);
if(str == "MO" || str == "TU" || str == "WD" || str == "FR")
{
if(arr[0] > 7 && arr[0] < 21)
{
rate= arr[2] * .30;
}
else if (arr[0] <=7 || arr[0] >21)
{
rate=arr[2] * .15;
}
}
else
{
rate=arr[2] * .10;
}
cout<<rate<<endl;
}
void main()
{
string str;
int arr[3];
char ch='y';
while(ch == 'y' || ch == 'Y')
{
cout<<"please enter the day eg:Mo"<<endl;
cin>>str;
cout<<"please enter the time the call was in and the duration"<<endl;
for(int i=0; i<3; i++)
cin>>arr[i];
calculate(str,arr);
cout<<"go again(y/n)"<<endl;
cin>>ch;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.