This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-12-04 13:32:04

amarmasic21
Scratcher
Registered: 2009-12-04
Posts: 3

Help with finding max number?

Hey I'm trying to make a small program in scratch that basically does the following:

REPEAT
    Prompt for how many numbers, or -1 to quit
    Read HowMany
    If (HowMany <> -1)
        Set Max to 0
        While ((HowMany > 0)
            Prompt for candidate number
            Read Num
            If (Num > Max)
                Set Max to Num
            Set HowMany to HowMany – 1
        Display Answer Message
        Display Max
UNTIL (HowMany = -1)
Display thank you message


But with what I have now it wont quit when -1 is pressed, and I cant seem to find a way to print the answer message?
I have the program on my account as what I have so far.

Offline

 

#2 2009-12-04 13:37:02

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Help with finding max number?

Well, I'm not seeing it on your account.  Maybe the server upgrade is interfering with the upload? 

To display the answer, use the Say block to print it to the screen in a speech bubble.  The Say block is only available for sprites (not available on the Stage) so hopefully you are doing your scripting on a sprite.

I'm not sure what's going on with the -1 exit condition....I think I'll wait until I can see the project before I hazard a guess.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#3 2009-12-05 00:42:39

amarmasic21
Scratcher
Registered: 2009-12-04
Posts: 3

Re: Help with finding max number?

Hey, yeah sorry it was affecting it its up now.. I slightly changed it. But yeah I have the basic thing down I'd just love some help fixing those two minor issues. Thanks a lot :]

Offline

 

#4 2009-12-05 00:55:56

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Help with finding max number?

For the -1 exit problem, try an = sign instead of <>.  wink


Hai.

Offline

 

#5 2009-12-05 21:24:46

amarmasic21
Scratcher
Registered: 2009-12-04
Posts: 3

Re: Help with finding max number?

Hey thanks that helped a lot, I posted what I have now, almost have it perfect, but how do I get it to say "The largest number entered was:" and "Thank you for using the program" once they quit?

Offline

 

#6 2009-12-05 21:32:20

deatheater
Scratcher
Registered: 2008-04-11
Posts: 1000+

Re: Help with finding max number?

ok, at the end of the

repeat until <how many=0>   (or just before the second, else
                                                                             stop all)

add a

say [(join|The largest number entered was: |(max))]

and then add

say[Thanks you for using the program]

underneath the first say

Offline

 

Board footer