Results 1 to 7 of 7
  1. #1
    beansnet is offline Member
    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0

    Default 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?

  2. #2
    beansnet is offline Member
    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0

    Default 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.
    Last edited by beansnet; 01-04-2013 at 04:20 PM.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,528
    Blog Entries
    7
    Rep Power
    20

    Default Re: Multiplication Tables game

    Quote Originally Posted by beansnet View Post
    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
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    beansnet is offline Member
    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0

    Default 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."

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Multiplication Tables game

    Please go through the Forum Rules, particularly the second paragraph. I've merged your two threads here.

    You probably also need to go through Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Multiplication Tables game

    Quote Originally Posted by beansnet View Post
    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
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,528
    Blog Entries
    7
    Rep Power
    20

    Default 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
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Multiplication practice app
    By Mikki in forum New To Java
    Replies: 4
    Last Post: 06-24-2012, 11:38 PM
  2. Secondary input bug within times tables game,
    By Martyn in forum New To Java
    Replies: 14
    Last Post: 01-09-2012, 01:56 AM
  3. need help with multiplication
    By dakid2 in forum New To Java
    Replies: 10
    Last Post: 03-08-2011, 03:41 AM
  4. Help with Multiplication
    By phil028 in forum New To Java
    Replies: 1
    Last Post: 12-06-2007, 07:39 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •