I have an assignment due this week in which I need to prompt a user for ten numbers, and then after all numbers are entered, display the largest.
I can't figure it out, and I feel like an idiot because it's not exactly a hard program, i just can't do it.
Any suggestions, hints? I've gone through tons of tutorials, but nothing seems to explain how to do something like this... >.<
Have scratch 1.4
Offline
Hold on I'm working it out
EDIT: I don't have access to my computer with Scratch on it right now. I'll have get to you later
Last edited by militarydudes (2010-09-05 15:39:39)
Offline
Considering this is an assignment, I won't give you the exact scripts. But I will give you general instructions on how to do this - you're not an idiot, by the way.
Using the "Ask" blocks, as the user for the first number, and put that number into a list. Do the same for the other 9 numbers. Be sure to have the list cleared before the project starts, too.
Then, compare the first item of the list to the second item of the list, and put the larger of the numbers into a variable. Compare that number to the third number, if it's larger, replace the number. Repeat the process for all ten items of the list.
Hopefully that will help you out a bit... If it's not clear enough, I can elaborate which blocks should be used.
Offline
Try making a variable, and set it to 0 at the beginning of the project.
Then, as you ask the person, if the number is higher than the variable, set the variable to the answer.
That is the fastest way.
Offline
So far this is what I'm looking at... (sorry I can't put it in as an image. Apparently i'm too new)
http://i10.photobucket.com/albums/a115/Falkon114/Picture1-16.png
It's a good step, need to tinker with some things I suppose, but... its not working just right
Offline
Alright, I figured out that program. Ended up writing it like so:
http://i10.photobucket.com/albums/a115/Falkon114/Picture2-12.png
The next part of my assignment is to ask the user for an upper range limit, take a random number, and have the user try to guess it. Print "higher" if their guess is low, "lower" if their guess is high, and say "you win" if they guess it within x tries, "you lose" if they dont.
This is my progress on that....
http://i10.photobucket.com/albums/a115/Falkon114/Picture3-5.png
Thanks for help, and any other hints or suggestions? Like the previous program, I clearly need to mess around a bit more.
Offline
Make a variable (I'll call it "tries"). At the beginning, set "tries" to 0. Instead of using "repeat (5)", use a "repeat until." Every time it repeats, change "tries" by one. Make it repeat until "tries" is more than x OR the answer is correct. If the answer is correct, give your "correct" answer. Otherwise, give your "you lose" message. Does that help?
Offline