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.

>> REGISTER NOW TO START POSTING

1. ## 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. ## 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)
* 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
* 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.

3. 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. ## 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. ## 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.