#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# i really need help with a simple progam

Posts: 3Member
hey everyone,

i have an assignment for a class in college, and i have to write a pascal program, but the last time i did anything in pascal was probably 10 years ago, so i really dont remember much...

so anyway, this program has to calculate the cost of a phone call after you enter the length of the call. so, you have to enter the number of minutes and the number of seconds as variables (i think). the cost of one minute is 1.22.

if anyone has any ideas, or if anyone would be so kind as to write the program :))), i would be very grateful, and you would save me from failing the class :)
· ·

• Posts: 5Member
: hey everyone,
:
: i have an assignment for a class in college, and i have to write a
: pascal program, but the last time i did anything in pascal was
: probably 10 years ago, so i really dont remember much...
:
: so anyway, this program has to calculate the cost of a phone call
: after you enter the length of the call. so, you have to enter the
: number of minutes and the number of seconds as variables (i think).
: the cost of one minute is 1.22.
:
: if anyone has any ideas, or if anyone would be so kind as to write
: the program :))), i would be very grateful, and you would save me
: from failing the class :)
:
Writing the progrma for you would be considered cheating but the basic formula to follow is:
Call_Length_Minutes * 1.22

I am a C++ guy so im sorry if this may differ. But your language should have equivilents.
Call_Length_Minutes is a float variable that holds a decimal value. For example if the call was 1 minute 56 seconds long. Put it into the variable as Call_Length_Minutes = 1.56
Then multiply that number by the cost to get the total. From there just display it.

· ·
• Posts: 111Member
: Writing the progrma for you would be considered cheating but the
: basic formula to follow is:
: Call_Length_Minutes * 1.22
:
: I am a C++ guy so im sorry if this may differ. But your language
: should have equivilents.
: Call_Length_Minutes is a float variable that holds a decimal value.
: For example if the call was 1 minute 56 seconds long. Put it into
: the variable as Call_Length_Minutes = 1.56
: Then multiply that number by the cost to get the total. From there
: just display it.

Acutally, doing just "Call_Length_Minutes * 1.22" won't be enough as there are 60 seconds to a minute, not 100. :)
· ·
• Posts: 3Member

: Acutally, doing just "Call_Length_Minutes * 1.22" won't be enough as
: there are 60 seconds to a minute, not 100. :)

yeah, exactly, and thats the problem! i tried "minutes X 1.22" before, and it doesnt work, becouse of the 60 second thing. but thanks anyway :)

anyone else have a suggestion?

· ·
• Posts: 757Member
:
: : Acutally, doing just "Call_Length_Minutes * 1.22" won't be enough as
: : there are 60 seconds to a minute, not 100. :)
:
:
: yeah, exactly, and thats the problem! i tried "minutes X 1.22"
: before, and it doesnt work, becouse of the 60 second thing. but
: thanks anyway :)
:
: anyone else have a suggestion?
:
:

Cost := (Round(minutes) + (Minutes-Round(Minutes))*100/60) * 1.22;
(
By rounding MINUTES, you will get only the full minutes (no seconds)
Therefore, MINUTES-ROUND(MINUTES) will give you .59
.59 * 100 / 60 = 0.9833 of a minute.
Add whole minute amount of 1 to 0.9833 and you get 1.9833 minutes on the call. Then just multiply by the cost per minute ;)

Phat Nat
· ·
• Posts: 3Member
thanks alot, ill try that!
· ·
• Posts: 438Member
: hey everyone,
:
: i have an assignment for a class in college, and i have to write a
: pascal program, but the last time i did anything in pascal was
: probably 10 years ago, so i really dont remember much...
:
: so anyway, this program has to calculate the cost of a phone call
: after you enter the length of the call. so, you have to enter the
: number of minutes and the number of seconds as variables (i think).
: the cost of one minute is 1.22.
:
: if anyone has any ideas, or if anyone would be so kind as to write
: the program :))), i would be very grateful, and you would save me
: from failing the class :)
:

Just do the math.

If Minutes and Seconds are entered separately then
[code]
Cost := 1.22 * (Min + (Sec / 60.0)) ;
[/code]
Presumably the variables are declared as
[code]
var
Cost : real ;
Min,
Sec : integer ;
[/code]
You need to be certain that the expression on the right evaluates as a real. I'll leave that up to you.
· ·