I need help to make a countdown date RRS feed

  • Question

  • Hi guys,

    For school we have to make a Basic program that checks your age and if you are younger than 17 it says "Not yet" and if your older it says "You can drive!".

    When you are too young I want it to tell you the date when you are able to drive. What would be the code?

    My code is pasted below...

    TextWindow.Title = "Car Hire"
    TextWindow.WriteLine("What is your age?")
    Age = TextWindow.Read() 'Age is a "variable", a variable is a place in the Computers memory.'
    TextWindow.WriteLine("Your age is " + Age)

    If Age <=17 Then
      TextWindow.WriteLine("Not yet!")

    If Age >=17 Then
      TextWindow.WriteLine("You can drive!")

    Thursday, June 4, 2015 6:00 PM


  • The members of the forum are not big on doing students homework for them. However since you have something that mostly works, I can give you a pointer or two.

    The reason you are seeing two messages when the value is 17 is that both of your If statements are sporting equal signs. If you drop the equal from the first IF (If Age <17 Then) you will get the result you are looking for.

    A better solution is to skip the second If statement entirely and join the two ideas together with an else:

    If Age < 17 Then Else EndIf

    This is true of any condition that is either/or.   With if you are matching one very specific thing, and else picks up everything else in the universe.

    Thursday, June 4, 2015 6:48 PM