Hi all,
How would I code this problem, A button generates a random number between 40 and 70 and
displays it on the screen in a box or field (not sure what to use to display this) and then the button is disabled.
Then another button also generates a random number between 1 and 10 subtracting it from the
first random number and displays it on a screen in a box or field.
Example: Press button, Say random number 45 shows up on the screen. Disable button.
Then second button pressed, say the random number is 8, so 37 shows up on the screen in a box or field or ?
I am using NetBeans for this project. Here is the code I am using to generate the random numbers. I am using the same code for the 40 to 70 and 1 to 10, Just changing the ranges.
public class Randomizer
{
public static int generate(int min,int max)
{
return min + (int)(Math.random() * ((max - min) + 1));
}
public static void main(String[] args)
{
System.out.println(Randomizer.generate(1,10));
}
}
I am not sure what display type I should use either, ie Button, text feild, panel, pane???
cause I want the box of field to blink or flash when the second button is = to or less than 10. I want to have 9 boxes or fields to represent
the last number and blink in that box or field. So there will be 9 boxes or fields numbered 1,2,3,4,5,6,7,8 and 9 an 10 will have the same box and if 9 or 10 is the last number it will blink on that box.
Any Ideas?
Thanks
How would I code this problem, A button generates a random number between 40 and 70 and
displays it on the screen in a box or field (not sure what to use to display this) and then the button is disabled.
Then another button also generates a random number between 1 and 10 subtracting it from the
first random number and displays it on a screen in a box or field.
Example: Press button, Say random number 45 shows up on the screen. Disable button.
Then second button pressed, say the random number is 8, so 37 shows up on the screen in a box or field or ?
I am using NetBeans for this project. Here is the code I am using to generate the random numbers. I am using the same code for the 40 to 70 and 1 to 10, Just changing the ranges.
public class Randomizer
{
public static int generate(int min,int max)
{
return min + (int)(Math.random() * ((max - min) + 1));
}
public static void main(String[] args)
{
System.out.println(Randomizer.generate(1,10));
}
}
I am not sure what display type I should use either, ie Button, text feild, panel, pane???
cause I want the box of field to blink or flash when the second button is = to or less than 10. I want to have 9 boxes or fields to represent
the last number and blink in that box or field. So there will be 9 boxes or fields numbered 1,2,3,4,5,6,7,8 and 9 an 10 will have the same box and if 9 or 10 is the last number it will blink on that box.
Any Ideas?
Thanks