none
hot or cold guessing game RRS feed

  • Question

  • i need help to figuring out how to put cold if 3 away from random number, warm if 2 and hot if 1 away. also i dont understand how to tell them how many they got right and what their skill level is. any ideas on how to do this? i need to maybe see an example or more of an explanation of how to do it. thanks!
    Friday, December 4, 2015 9:48 PM

Answers

  • You could ask the user to pick a number between 1 and 10.

    Then get a random number and subtract them.

    Math.Abs(userPicked - randomNumber)

    If the difference < 4 then

    result = cold

    if  < 3 then

    result =warm

    if  < 2 then

    result =hot

    -------------------

    TextWindow("You're "+ result)

    Saturday, December 5, 2015 4:53 AM
    Moderator

All replies

  • You could ask the user to pick a number between 1 and 10.

    Then get a random number and subtract them.

    Math.Abs(userPicked - randomNumber)

    If the difference < 4 then

    result = cold

    if  < 3 then

    result =warm

    if  < 2 then

    result =hot

    -------------------

    TextWindow("You're "+ result)

    Saturday, December 5, 2015 4:53 AM
    Moderator
  • You could ask the user to pick a number between 1 and 10.

    Then get a random number and subtract them.

    Math.Abs(userPicked - randomNumber)

    If the difference < 4 then

    result = cold

    if  < 3 then

    result =warm

    if  < 2 then

    result =hot

    -------------------

    TextWindow("You're "+ result)

    thanks that really helped. now would that be in a sub or no? I know i need one sub in my program but i can't figure out where or what it would be.
    Saturday, December 5, 2015 4:34 PM
  • You could ask the user to pick a number between 1 and 10.

    Then get a random number and subtract them.

    Math.Abs(userPicked - randomNumber)

    If the difference < 4 then

    result = cold

    if  < 3 then

    result =warm

    if  < 2 then

    result =hot

    -------------------

    TextWindow("You're "+ result)


    instead of using result = cold, could i do textwindow.writeline("You are cold") ? is that the same type of thing or no?
    Saturday, December 5, 2015 4:42 PM
  • You could ask the user to pick a number between 1 and 10.

    Then get a random number and subtract them.

    Math.Abs(userPicked - randomNumber)

    If the difference < 4 then

    result = cold

    if  < 3 then

    result =warm

    if  < 2 then

    result =hot

    -------------------

    TextWindow("You're "+ result)


    instead of using result = cold, could i do textwindow.writeline("You are cold") ? is that the same type of thing or no?
    tried using the writeline and then i ran it but it did not work. the first time i would do it, i guessed the number or it just gave it to me the first time. i ran it a second time and same thing. the third time would always tell me i was cold and never give me a number or would say i was warm and never give me a number. how do i fix that error?
    Saturday, December 5, 2015 5:57 PM
  • Yeah it should be:

    If difference < 2

    hot

    ElseIf difference < 3

    warm

    Saturday, December 5, 2015 6:45 PM
    Moderator
  • Yeah it should be:

    If difference < 2

    hot

    ElseIf difference < 3

    warm


    its not working even if i try that. i dont get it to end or change depending on how far away it is. any other suggestions? I dont want it to keep saying your cold for every number i try like it does now. how to i fix that? i tried just about all i can think of and nothing works. Got any better ideas to try?
    Sunday, December 6, 2015 7:28 PM
  • Yeah it should be:

    If difference < 2

    hot

    ElseIf difference < 3

    warm


    its not working even if i try that. i dont get it to end or change depending on how far away it is. any other suggestions? I dont want it to keep saying your cold for every number i try like it does now. how to i fix that? i tried just about all i can think of and nothing works. Got any better ideas to try?

    and is this all in a sub or no? I did not get a clear answer. I know I need a sub in my program but i cannot figure one out. help with that too please.
    Sunday, December 6, 2015 7:30 PM
  • Elizabeth, did you read the Chapter "Subroutines" in the Small Basic manual? There is a clear explanation when and how to use subroutines.

    Link to that: http://download.microsoft.com/download/9/0/6/90616372-C4BF-4628-BC82-BD709635220D/Introducing%20Small%20Basic.pdf


    Jan [ WhTurner ] The Netherlands

    Tuesday, December 8, 2015 11:33 AM
    Answerer