Design and write an ArithmeticGUI class that allows users to input play with numbers multiplication. The GUI should contain three JTextField, one for input first number, second for second number and third for the result of multiplication of both numbers. There should be one button which the user can signal that correct multiplication result has been entered. The multiplication table of the second number should be displayed in the text area and the correctness of the multiplication result should also be displayed in a text field, but this should be set uneditable. A sample Arithmetic GUI interface is displayed below:
If users input a correct multiplication result of two numbers, the below should happened:
If users input a wrong multiplication result of two numbers, the below should happened:
i've already try it but i have problem at the for loop structure...
here the java code that i try..
I'm not sure what you are trying to do here. What you have in your parens: "num1 * num2 == result" is essentially a boolean. it's either 'true' or 'false'.
A 'for' statement doesn't take a boolean - it takes three things for setting up, testing, and updating variables. Then, the code inside the curly brackets potentially runs multiple times.
So really, the question is, what are you trying to DO there? Are you trying to test something? i don't think so, because it's a repeat of what's in your if statement just above it.
I assume you are trying to loop around and print out all those products.
So, as others have said, look in a book or online tutorial for how to set up a for-loop. Then, see if you can write one that does nothing more that prints "hello" 12 times. Then get it to print something like:
1
2
3
4
5
6
7
8
9
10
11
12
etc, and add a little bit each time.
Never ascribe to malice that which can be adequately explained by stupidity.
ELL TIM
Greenhorn
Joined: Mar 24, 2009
Posts: 3
posted
0
fred rosenberger wrote:
for (num1 * num2 == result) //(have problem)
I'm not sure what you are trying to do here. What you have in your parens: "num1 * num2 == result" is essentially a boolean. it's either 'true' or 'false'.
A 'for' statement doesn't take a boolean - it takes three things for setting up, testing, and updating variables. Then, the code inside the curly brackets potentially runs multiple times.
So really, the question is, what are you trying to DO there? Are you trying to test something? i don't think so, because it's a repeat of what's in your if statement just above it.
I assume you are trying to loop around and print out all those products.
So, as others have said, look in a book or online tutorial for how to set up a for-loop. Then, see if you can write one that does nothing more that prints "hello" 12 times. Then get it to print something like:
1
2
3
4
5
6
7
8
9
10
11
12
etc, and add a little bit each time.
Sorry bout the code,i'm new to this site..also new to java programming...the thing is i want the output to print out like this when user key in the second number,then the multiplication are base on the second number.
1 x 2 = 2
2 x 2 = 4
3 x 2 = 6
4 x 2 = 8
...
...
...
12 x 2 = 24
i try using this code but still cant get what i want..
one of the hardest things to learn as a new programmer is to not try and do too much at once. The less you try and accomplish on each build/debug/test cycle, the easier it is to find your problems.
So, I'd suggest this:
try and write code that when the user enters their second number, you get it to print the number 1-12, each on a new line. Get that to work. ONLY after you are sure that is working perfectly, try and change it to print
1 x <the input second number>
2 x <the input second number>
... etc
ONLY after you have that working, try and get it to print the actual product on the end.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
4
posted
0
ELL TIM wrote:..also new to java programming...
Has whoever is teaching you not taught you about the structure of a for loop?
ELL TIM
Greenhorn
Joined: Mar 24, 2009
Posts: 3
posted
0
just figured it out actually. Thanks for the tips! (^_^)