# Multiplication Tables game

• 01-04-2013, 04:56 PM
beansnet
Multiplication Tables game
Design, implement and test a Java program which presents the user with the following menu.

1 ... Times tables – (select and view)
2 ... Practise - (select and practise)
3 ... New game - (10 random times tables sums)
4 ... Quit

Enter option ....

1. When this option is chosen, the user is asked to input a number 1- 12. The times tables for that number shall then be displayed.

2 When this option is chosen, the user is asked for a number (1 to 12) and then the user is prompted for the result of each time table for the number starting at 1 and incrementing to 12. If the user gets the sum correct then an appropriate message is displayed and if incorrect the correct answer is displayed. At the end of the series the number of correct answers the user gets is displayed.

3 When this option is chosen, the program displays 10 random times table sums (limited to 1 to 12 only) to complete. If the user gets the sum correct then an appropriate message is displayed and if incorrect the correct answer is displayed. At the end of the series the number of correct answers is displayed.

I've done the first part of question 1, but I can't get the validation to work.
e.g if (option < =0 || Choice >=13) {
System.out.println( "Invalid. Please enter a number between 1 & 12);

What am I doing wrong?
• 01-04-2013, 05:00 PM
beansnet
Multiplication Tables game
Design, implement and test a Java program which presents the user with the following menu.

1 ... Times tables – (select and view)
2 ... Practise - (select and practise)
3 ... New game - (10 random times tables sums)
4 ... Quit

Enter option ....

1. When this option is chosen, the user is asked to input a number 1- 12. The times tables for that number shall then be displayed.

2 When this option is chosen, the user is asked for a number (1 to 12) and then the user is prompted for the result of each time table for the number starting at 1 and incrementing to 12. If the user gets the sum correct then an appropriate message is displayed and if incorrect the correct answer is displayed. At the end of the series the number of correct answers the user gets is displayed.

3 When this option is chosen, the program displays 10 random times table sums (limited to 1 to 12 only) to complete. If the user gets the sum correct then an appropriate message is displayed and if incorrect the correct answer is displayed. At the end of the series the number of correct answers is displayed.

I've done the first part of question 1, but I can't get the validation to work.
e.g if (option <=0 || option >=13) {
System.out.println( "Invalid. Please enter a number between 1 & 12);

What am I doing wrong?
Really need help with this.
• 01-04-2013, 05:07 PM
JosAH
Re: Multiplication Tables game
Quote:

Originally Posted by beansnet
I've done the first part of question 1, but I can't get the validation to work.
e.g if (option < =0 || Choice >=13) {
System.out.println( "Invalid. Please enter a number between 1 & 12);

What am I doing wrong?
Really need help with this.

I don't know if those spaces are intentional, but the operators are "<=" and ">=", i.e. "if (option <= 0 || Choice >= 13) {" ... and make up your mind: is it 'option' or 'Choice'?

kind regards,

Jos
• 01-04-2013, 05:19 PM
beansnet
Re: Multiplication Tables game
Hi Jos,
Thanks for taking time out to help.

Sorry, I meant
"if (option <= 0 || option >= 13) {"

I have it written like this and it still won't work, it's saying "illegal start of expression."
• 01-04-2013, 05:49 PM
DarrylBurke
Re: Multiplication Tables game

You probably also need to go through http://www.java-forums.org/forum-gui...w-members.html and BB Code List - Java Programming Forum - Learn Java Programming

db
• 01-04-2013, 05:50 PM
DarrylBurke
Re: Multiplication Tables game
Quote:

Originally Posted by beansnet
I have it written like this and it still won't work, it's saying "illegal start of expression."

You're not trying to write executable code outside of any method or constructor, are you?

db
• 01-04-2013, 05:51 PM
JosAH
Re: Multiplication Tables game
You probably have put that code at the wrong place (i.e. not inside a method body) and the compiler complains about it.

kind regards,

Jos