## Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only

i really need help with a simple progam Posted by SectorSeven on 31 Aug 2008 at 8:09 AM
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 :)
Re: i really need help with a simple progam Posted by Flamingkat on 1 Sept 2008 at 7:22 AM
: 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.

Re: i really need help with a simple progam Posted by PP2005 on 1 Sept 2008 at 1:32 PM
: 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. :)
Re: i really need help with a simple progam Posted by SectorSeven on 2 Sept 2008 at 2:42 AM

: 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?

Re: i really need help with a simple progam Posted by Phat Nat on 3 Sept 2008 at 4:31 PM
:
: : 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?
:
:

How about:

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
Re: i really need help with a simple progam Posted by SectorSeven on 4 Sept 2008 at 2:31 AM
thanks alot, ill try that!
Re: i really need help with a simple progam Posted by Actor on 26 Sept 2008 at 9:32 AM
: 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
```Cost := 1.22 * (Min + (Sec / 60.0)) ;
```

Presumably the variables are declared as
```var
Cost : real ;
Min,
Sec  : integer ;
```

You need to be certain that the expression on the right evaluates as a real. I'll leave that up to you.

## Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.