locked
What is wrong with this code RRS feed

  • Question

  • Here is a peice of code from my program on small basic. What is wrong

    Time:
    TextWindow.WriteLine("What is the Mass of object One, in Kg")
    Mass1=Textwindow.Read()
    TextWindow.WriteLine("Thank, now what is the Distance between the two object, in metres")
    Distance=Textwindow.Read()
    "g"=((1/Distance*Distance)/6.674*10^-11)*Mass1
    "T"=Math.SquareRoot(2*Distance/g)
    TextWindow.WriteLine("Thank you, the time it will take to have contact is "+T+" seconds")

    It says  "g" unexpected at this location

    and "T" unexpected at this location

    I have tried many things

    Wednesday, December 23, 2015 3:02 PM

Answers

  • Variables can't be surrounded by quotation marks.

    So,  "g"=((1/Distance*Distance)/6.674*10^-11)*Mass1

    should be,  g =((1/Distance*Distance)/6.674*10^-11)*Mass1

    • Proposed as answer by WhTurner33Editor Thursday, December 24, 2015 9:02 AM
    • Marked as answer by Liam McSherry Thursday, December 24, 2015 9:20 AM
    Wednesday, December 23, 2015 10:23 PM

All replies

  • You define g and T as variables in your code so you can not write them in "..." here.
    Wednesday, December 23, 2015 4:45 PM
  • how do i make it work then

    Wednesday, December 23, 2015 6:59 PM
  • Variables can't be surrounded by quotation marks.

    So,  "g"=((1/Distance*Distance)/6.674*10^-11)*Mass1

    should be,  g =((1/Distance*Distance)/6.674*10^-11)*Mass1

    • Proposed as answer by WhTurner33Editor Thursday, December 24, 2015 9:02 AM
    • Marked as answer by Liam McSherry Thursday, December 24, 2015 9:20 AM
    Wednesday, December 23, 2015 10:23 PM
  • Thank you so so much

    Thursday, December 24, 2015 2:56 AM