Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Arithmetic Tester Program

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Thanked 0 Times in 0 Posts

    Default Arithmetic Tester Program

    my name is Dase Udumebraye, am new to the java programming language. A first year student at the university, i have an assignment to work on but i don't know how to go about it. below is the task description.

    How do i go about developing a simple arithmetic tester program which can be used to help young children improve their arithmetic skill. The program should accepts string data for the player’s name and the number of questions they want to try, which will be entered by the user.
    The program should take in the following inputs from the user:
    The name of the player, so that the game can refer to them by name in messages. The name must be between 2 and 20 characters inclusive.
    The number of sums that the user wants to attempt. This number must be a whole number, and be between 2 and 50 inclusive.
    The program must check that the values entered fall within the valid ranges. The program must also check that no empty strings are entered for names.
    Once the player has entered their name and the number of questions they want to attempt, the game begins. The program must generate sums for the player.
    The program should generate one question at a time and display the question for the user. The questions must involve two numbers and be either a multiplication, division, subtraction, or addition. For example, the following are all valid questions:
    3 * 4 = ?
    8 / 2 = ?
    7 + 1 = ?
    9 – 8 = ?

    The first number, second number, and arithmetic operator (multiply, divide, add, subtract) should all be chosen randomly, the program should Generate a new random number for each of the three parts of each sum. this requires you to choose one of the four symbols based on which random number is returned.
    A few checks must be carried out before a generated question is displayed to the user. If the question is an addition question, no checks are required. If the question is a multiplication question, no checks are required. However, checks are required for subtraction and division sums.
    If the question is a subtraction question, the program must check that the second number is equal to or smaller than the first number. Whilst the second number is larger than the first number, new numbers should be generated.

  2. #2
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    South England UK
    My Mood
    Thanked 61 Times in 55 Posts

    Default Re: Arithmetic Tester Program

    It's more or less pretty self-explained for you as a sort of algorithm
    already. What you need to do, in some form or another is:

    *Define a main method
    *Find out if you can use additional methods as well as main (recommended)
    * Define your variables
    * Ask for the input (within a loop condition so it repeats until valid - count the
    characters as well)
    * Ask for input on questions (again, in a loop format - testing until input is valid)
    * Create the main "game" loop - that repeats until user is finished
    * Generate a random number within the pseudo-rate given
    * Ask the math question - using the generated random numbers
    * Read input for answer and test if it is correct
    * Print new question with new random numbers if correct - repeat
    the same question if incorrect.

    That's all there is to it. I would approach this one step
    at a time - write the first part, compile it, debug it and if
    it works, move on the next step.

    Rinse and repeat until finished. Ask if you get stuck - but
    please post any code with the problem.

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    Augusta Ada Byron, Lady Lovelace (1851)

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Thanked 3 Times in 3 Posts


    That's a great little problem there to solve using Java.

    You just need to sit down and write yourself out an algorithm as Ada has stated, and make sure all steps are included. Whenever they are, you should have no problems writing code for them.

    I teach Java in secondary school and this is one program I always include.

  4. #4
    Junior Member
    Join Date
    Aug 2014
    Thanked 0 Times in 0 Posts

    Default Re: Arithmetic Tester Program

    good day, am Dase udumebraye. you said you teach java in secondary school. how can i get access to your training materials? pls help me with the materials you use. i am new to java i really want to go deep with it.

  5. #5
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 697 Times in 679 Posts

    Default Re: Arithmetic Tester Program

    @DASE: Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    There are free Java books and tutorials available online, just search for them.

Similar Threads

  1. how to make a program that does the following arithmetic expressions ?
    By deathpain in forum Java Theory & Questions
    Replies: 13
    Last Post: November 18th, 2011, 06:12 PM
  2. simple arithmetic problem
    By nadrii in forum What's Wrong With My Code?
    Replies: 15
    Last Post: October 26th, 2011, 09:35 PM
  3. Help with modifying a program for evaluating arithmetic expressions
    By rockout341 in forum Object Oriented Programming
    Replies: 5
    Last Post: October 13th, 2011, 11:01 AM
  4. doing arithmetic on Integer objects
    By gib65 in forum Java Theory & Questions
    Replies: 4
    Last Post: October 30th, 2010, 09:22 PM
  5. Arithmetic’s Game ??
    By holy crab in forum Algorithms & Recursion
    Replies: 0
    Last Post: April 12th, 2010, 04:27 AM