
-----------------------------------
JamesXm
Sat Jun 24, 2006 1:06 pm

Acceleration calculations.
-----------------------------------
I need help with real numbers. When I run this program I wrote, rounded numbers appear.
Try this:
-start the program
-hit a to calculate acceleration
-intial speed  = 0 final speed = 25 time = 10
-the answer appears as 2. but it should be 2.5

Any help is greatly appreciated. :) 


View.Set ("graphics")
View.Set ("title:Acceleration Calculator - JamesXm")
var a, v1, v2, v, t : real
var whattofind : string

procedure finda
    v := v2 - v1
    a := v div t
    put "Step One:"
    put ""
    put v2, "-", v1
    put "divided by"
    put t
    put ""
    put "Step Two:"
    put ""
    put v
    put "divided by"
    put t
    put ""
    put "Step Three:"
    put ""
    put a
    put ""
    put ""
    put "Therefore, the acceleration is " ,a:2

end finda

procedure findv1

end findv1

procedure findv2

end findv2

procedure findt

end findt

put "What are you trying to find? (enter a, b, c, or d)"
put "a) Acceleration (m/s2)"
put "b) Initial Speed (m/s)"
put "c) Final Speed (m/s)"
put "d) Time (s)"
get whattofind
cls
if whattofind = "a" then
    put "Initial Speed (m/s):"
    get v1
    put "Final Speed (m/s):"
    get v2
    put "Time (s):"
    get t
    cls
    finda
elsif whattofind = "b" then
    put "Acceleration (m/s2):"
    get a
    put "Final Speed (m/s):"
    get v2
    put "Time (s):"
    get t
    cls
    findv1
elsif whattofind = "c" then
    put "Acceleration (m/s2):"
    get a
    put "Initial Speed (m/s):"
    get v1
    put "Time (s):"
    get t
    cls
    findv2
elsif whattofind = "d" then
    put "Acceleration (m/s2):"
    get a
    put "Initial Speed (m/s):"
    get v1
    put "Final Speed (m/s):"
    get v2
    cls
    findt
else
    put "Restart the program! An error has occured."
end if


-----------------------------------
Delos
Sat Jun 24, 2006 1:15 pm

Re: Acceleration calculations.
-----------------------------------


a := v div t 



Use '/' instead of 'div'.  The div operator truncates remainders.

-----------------------------------
upthescale
Sat Jun 24, 2006 1:17 pm


-----------------------------------
First of all at the top you have Two View.Sets. Why not just put the title in with the graphics?

View.Set("graphics;title:...")

second of all i think your problem is 'div' but im not to sur sorry

-----------------------------------
JamesXm
Sat Jun 24, 2006 1:18 pm


-----------------------------------
Thank you. I have it working now.  8-)
