none
Expected here, but not could not find" error RRS feed

  • Question

  • Can someone please tell me why I am getting the error "11,1 Expected here, but not could not find" error?

    Thanks!

    TextWindow.WriteLine("Welcome to the BMI calculator")
    TextWindow.writeline("Enter weight in kg")
    weight =TextWindow.ReadNumber()
    TextWindow.writeline("Enter height in m")
    height = TextWindow.ReadNumber()
    BMI=weight/(height*height)
    TextWindow.Write("BMI is ")
    TextWindow.WriteLine (BMI)
    If (bmi < 18.5) Then
    BMI="Underweight"
    Elseif  "bmi >= 18.5 && bmi < 25.0"Then
      TextWindow.WriteLine  ("Normal")
    Elseif "bmi >= 25.0 && BMI < 30.0" Then
      TextWindow.WriteLine ("Overweight")
    Else
     TextWindow.WriteLine ("Obese")
    EndIf

    Monday, September 16, 2013 4:45 PM

Answers

  • Cannot reproduce an error.

    My guess it is an internationalization issue.  Try entering numbers with a . not ,

    With my UK internationalization I cannot enter a , for a number, but perhaps you can.

    Also your elsif statements are badly formed and doesn't work as you expect (should not be inside quotes and use And, not &&). 

    Consider this test:

    BMI = 20
    If (bmi < 18.5) Then
      BMI="Underweight"
    Elseif  "bmi >= 18.5 && bmi < 25.0"Then
      TextWindow.WriteLine  ("Normal")
    Elseif "bmi >= 25.0 && BMI < 30.0" Then
      TextWindow.WriteLine ("Overweight")
    Else
      TextWindow.WriteLine ("Obese")
    EndIf 

    Use:

    bmi = 20
    If (bmi < 18.5) Then
      TextWindow.WriteLine ("Underweight")
    Elseif  (bmi >= 18.5 And bmi < 25.0) Then
      TextWindow.WriteLine  ("Normal")
    Elseif (bmi >= 25.0 And bmi < 30.0) Then
      TextWindow.WriteLine ("Overweight")
    Else
      TextWindow.WriteLine ("Obese")
    EndIf
    Also I would not set BMI to a string "Underweight", when it is also being used to hold numbers.

    • Edited by litdevModerator Monday, September 16, 2013 5:51 PM
    • Marked as answer by jdmd111 Monday, September 16, 2013 6:57 PM
    Monday, September 16, 2013 5:20 PM
    Moderator

All replies

  • I never saw this ERROR.

    But your code works fine for me.


    Mit freundlichen Grüßen Timo Greetings Timo


    • Edited by Timo Sö Monday, September 16, 2013 5:07 PM
    Monday, September 16, 2013 4:57 PM
  • Cannot reproduce an error.

    My guess it is an internationalization issue.  Try entering numbers with a . not ,

    With my UK internationalization I cannot enter a , for a number, but perhaps you can.

    Also your elsif statements are badly formed and doesn't work as you expect (should not be inside quotes and use And, not &&). 

    Consider this test:

    BMI = 20
    If (bmi < 18.5) Then
      BMI="Underweight"
    Elseif  "bmi >= 18.5 && bmi < 25.0"Then
      TextWindow.WriteLine  ("Normal")
    Elseif "bmi >= 25.0 && BMI < 30.0" Then
      TextWindow.WriteLine ("Overweight")
    Else
      TextWindow.WriteLine ("Obese")
    EndIf 

    Use:

    bmi = 20
    If (bmi < 18.5) Then
      TextWindow.WriteLine ("Underweight")
    Elseif  (bmi >= 18.5 And bmi < 25.0) Then
      TextWindow.WriteLine  ("Normal")
    Elseif (bmi >= 25.0 And bmi < 30.0) Then
      TextWindow.WriteLine ("Overweight")
    Else
      TextWindow.WriteLine ("Obese")
    EndIf
    Also I would not set BMI to a string "Underweight", when it is also being used to hold numbers.

    • Edited by litdevModerator Monday, September 16, 2013 5:51 PM
    • Marked as answer by jdmd111 Monday, September 16, 2013 6:57 PM
    Monday, September 16, 2013 5:20 PM
    Moderator
  • Thank You! I got it to work.
    Monday, September 16, 2013 6:57 PM
  • Thanks!
    Monday, September 16, 2013 6:58 PM
  • If you are using ElseIf it is not nessesary to test e.g for bmi>=18.5 as you can only reach this if if bmi is not <18.5

    Jan [ WhTurner ] The Netherlands

    Tuesday, September 17, 2013 10:52 AM
    Answerer