
-----------------------------------
Hopping
Sun Mar 25, 2012 1:31 pm

Long Distance Call Program - Please HELP
-----------------------------------
What is it you are trying to achieve?
I'm trying to write this program that takes input from the user to calculate the cost of his/her long-distance call. I take input such as Day of the Week, length of call, when the call started, etc...There are also specific rates for the calls:

- Between 8:00 AM & 6:00 PM, Monday through Friday, is billed at a rate of $0.50 per minute.
- Before 8:00 AM or after 6:00 PM, Monday through Friday, is charged at a rate of $0.40 per minute.
- Started on a Saturday or Sunday is charged at a rate of $0.25 per minute.


What is the problem you are having?
Saturday & Sunday is fine. No problem there. I have made the program and the calculations are fine. However, one thing that I did not take into account is that from Monday to Friday, what if the call starts in one rate period and ends in another. The calculation will need to calculate both rates and add them together. For example, on Tuesday, if someone starts the call at 5:50 PM and talks for 20 mins, that means from 5:50 to 6, it's charging $0.40 per min and after that until 6:10 it's charging $0.50. I've made it so that only the starttime rate is calculated, which is not right as it needs to be able to do cross-rate calculations.


Describe what you have tried to solve this problem
I have no clue what to do. Tried to do it on paper first but still, my brain isn't working. Please help


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
This is my program without the cross-rate calculations. It works but can't do it if the user call goes from one rate to another.



var day:string
var start,long:int
var cost:real

put "Please enter the day of the week you called (first letter capitalized)..."
get day
put ""
put "Please enter the time you started the call in military (24hr) form without the colon."
put "For example, 8:30 PM = 2030, 12:30 AM = 030, 3:15 AM = 315, 11:45 PM = 2345, etc..."
get start
put ""
put "Please enter how long you talked in minutes..."
get long
put ""

if (day="Monday" or day="Tuesday" or day="Wednesday" or day="Thursday" or day="Friday") and (start>=800 and start