Link to home
Start Free TrialLog in
Avatar of Diverden
Diverden

asked on

Write a program that computes the cost of a long-distance call. The cost of the call is determined according <br>to the following

A. any call started between 8 am and 6 pm, Mon-Fri, is billed at a rate of .40 per minute
B. any call starting before 8 am or after 6 pm M-F should be billed at .25 per minute
C. any call started on Sat ot Sun is charged at a rate of .15 per minute
The input will consist of the day of the week, the time the call started, and the length of the call in minutes. The output will be the cost of the call. The time is to be input in 24hr notation and the day of the week as Mo/ Tu/ We/Th/Fr/sa/Su
The number of minutes will be input as a value of "int". There should be a loop that lets the user repeat the calculation until they are done. When this program is finished and debugged, write a variant that will read the information for all of the phone calls in one week from a file and then writes a phone bill to another file. The phone bill would show each call, and the charge for each call plus the total for all calls. List the phone calls in the same order as the appear in the input file.

I think I have the logic correct, the input will be day of the week, time the call starts, and length of call (int) and the output will be the cost. I have to make a loop to be able to do multiple computations, before I tell it to quit. If the logic is right then I need with the syntax.

#include<iostream.h>
day(Mo,Tu,We,Th,Fr,Sa,Su);
double length_of_call;
rate_1(day,length_of_call,.40)
rate_2(day,length_of_call,.25)
rate_3(day,length_of_call,.15)
{
int choice=1;
while(choice==1;     //initializing the start of the while loop

cout<<" please enter the day of the week the call was made"<<endl;

cin>>(Mo,Tu,We,Th,Fr,Sa,Su);
cout<<"please enter the hour the call started in military time"<<endl;
cin>>hour;
cout<<"please enter the minute the cal started"<<endl;
cin>>minute;
cout<<"please enter the length of the call in minutes"<<endl;
cin>>minutes;

}
double rate_1(day*length_of_call*rate);
}
double rate_2(day*length_of_call*rate);
}
double rate_3(day*length_of_call*rate);
}
if day==(Mo,Tu,We,Th,Fr)
{
&& 0800<timestart<1800;
}
cost_of_call==(minutes*.40)
{
if day==(Mo,Tu,We,Th,Fr)
&& 1800<timestart<0800;
}
cost_of_call==(minutes*.25)
{
if day==(Sa,Su)
}
cost_of_call==(minutes*.15)
cout<<"Do you want to enter another number and run this program again"<<endl;
cout<<"1.Yes"<<endl;
cout<<"2.No"<<endl;
cin>>choice;
while((choice!=1)&&(choice!=2))
{
cout<<"Please enter a valid choice"<<endl;
cin>>choice;
if(choice==2)
cout<<"\n Please hit any key to end the program"<<endl;

}
return 0;
}






ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to refund the points and delete this question since nobody had an answer for you.

The link to the Community Support area is: https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Avatar of Netminder
Netminder

Force/accepted by

Netminder
Community Support Moderator
Experts Exchange
Netminder, I think you should delete this question instead of force accepting an answer which is obviously not an answer.

hongjun
Yep, I think our friend was in the 'accept nietod' mode from the question before that ... ;-)

======
Werner
*smile*... Actually, I was in my "Accept anyone who spanks a student for asking us to do his homework" mode. There's a big part of me that appreciates nietod's untiring efforts to get people to understand that our doing someone else's work is tantamount to cheating on a test; there's a huge difference between that and assisting someone with a problem.

The argument that nietod didn't answer the question is, of course, a good one, and therefore, the argument that he's undeservedly received points and an A for doing nothing the logical conclusion. I disagree, because I think the only people who might "buy" this question from the PAQ are other students who would be trying to skate around learning something by cheating the system -- essentially, getting something for nothing. If a student trying to find a solution unethically pays something for nothing, then he/she deserves it for trying to cheat.

In the long run, a cheater will cheat; having read hundreds of attempts to get one's homework done at this site, I'm always amazed at the number of Experts willing to get points for doing the wrong thing (or helping someone else do the wrong thing), even when they're TOLD that doing a student's homework for him/her is a violation of the membership agreement. It's high time, in my estimation, that someone was rewarded for doing the RIGHT thing.

Netminder
Netminder

I have no problem at all that nietod gets these points. As you stated already, he is one of those who always tell students that we are not doing their homework. I feel that these askers shouldn't get their points refunded if they are not coming back with real questions. (And that's what I am suggesting in my C++ cleanup already).

I just feel uncomfortable that people might search for a solution for one of these problems, pay the price to get in and get .... nothing ....

Let's delete this Q, please and nietod will keep his deserved points.

======
Werner
Werner,

*grin*... that's my point. If someone buys this question, the odds are that he/she is another student taking the same course and is stumped by (or too lazy to figure out) the same question.

To me, it's like getting caught with a purchased term paper -- you shouldn't be surprised, and you have no complaint, if you fail a class you cheated to try and pass.

I'll leave it open until I hear from nietod, or until late this afternoon... then I'll delete it... *sigh*

Netminder
Sorry, I got you ... looking at the question again, it's too obvious, you are right ...

OK, I agree, let's have some fun :-) But it would be nice to KNOW if someone bought it ...

======
Werner
<laughing>

If someone does, I'm certain that one of two things will happen: Either we'll see a CS question asking for a refund, or we'll never hear about it because someone has actually been caught trying to cheat.

N