Solved Random Number Comparison to specify response

February 24, 2014 at 13:25:44
Specs: Windows 8.1
windows shell scripting-- compare numbers in a range
I need to compare a user generated number with the computer generated random number.
If it is within 200 I will echo getting warm
If it is within 20 I will echo getting hot
If it is within 5 I will echo WOW! almost.....

I cant figure out how to write it.

If %usernumber% -ge: (%random% +200) echo ....

I'm at a loss.

Any suggestions?


See More: Random Number Comparison to specify response

Report •


#1
February 24, 2014 at 13:29:03
0101Mark: windows shell scripting
Which language are you talking about? Windows has 2 to 4 native scripting languages, depending on where you draw the lines and the versions involved. Windows' shell is Explorer, and while it can be scripted, it by itself does not recognize any scripting language.

How To Ask Questions The Smart Way


Report •

#2
February 24, 2014 at 13:46:22
Sorry.... New and taking this for college.

It is Basic Shell Scripting, not the PowerShell.


Report •

#3
February 25, 2014 at 13:26:34
✔ Best Answer
Hi Mark: yeh, it looked like homework, but at least you admit that (homework-problem submissions to the forum are "frowned upon" as somewhat crass and unethical). So, with that said, I will give you a couple of pointers but not write the script - that's your job.
First, subtract your two numbers (random minus user). Get rid of the negative, if there is one, in the result. Begin comparisons with the lowest (zero), then go up from there (5, 20, 200)
That's my version, anyway, although there may be others, and I've probably already given away too much assistance. I advise you to make friends with the smart kid in the class (there's always at least one). Buy him/her a couple of beers and then start an informal conversation: "by the way, about that problem in chapter 2..." Ha ha! ;)

message edited by nbrane


Report •

Related Solutions

#4
February 26, 2014 at 11:13:17
I'm assuming this response is a little late, but you can't nest statements like your example. Subtract the random number from the guess, negate as necessary, and test against the result.

How To Ask Questions The Smart Way


Report •


Ask Question