How do I generate a random math addition question in Java?

  • Thread starter Thread starter xLaser
  • Start date Start date
  • Tags Tags
    Homework Java
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 2K views
xLaser
Messages
54
Reaction score
0
Question: Write a program which displays a random math addition question, asks the user for the answer and tells them whether they are correct or not.

ok, what is the command in java that creates an random math additon question?@#$% I have never heard of something like this before!
 
Physics news on Phys.org
There isn't one! Writing that functionality is part of your assignment.

(Java does have a feature for generating random numbers, though! Check out the `Random' class)
 
I think what the program specifications are asking you is to write a program that picks two numbers and asks the user to input their sum.

Like Hurkyl said, there is a Random class and an object of that class has a nextInt(max) method that will pick a random integer from 0 to max (I forget if it's inclusive or not).