Hailstone Lab

Make these objects work as described using the starter code on your drive:

  1. The Set button:
    1. IF there is a number in the textField that is >0,
      • set number to the value in the textfield.
    2. otherwise
      • randomly choose a number from 1-100 and display it on label 1
    3. set count to 0
    4. display number on label 1
    5. display Iterations: 0 on label 2
  2. The Next button:
  3. Quit button: ends the program:

 

hailstone panel

Top score:

Checking to see if there is any input:

String input = box.getText();         // get the text out of the text field named box
 if(input.length()>0){                // if there is something in the box
 number=Integer.parseInt(input);}     // turn it into an int
 else{                                //otherwise
 number =(int)(Math.random()*100)+1;} //generate a random number