i really need help with a simple progam

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

Comments

  • : 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.

  • : 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. :)

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

  • :
    : : 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
  • thanks alot, ill try that!
  • : 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.
Sign In or Register to comment.

Howdy, Stranger!

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

Categories