PDA

View Full Version : Java Homework, a little help.


xLaser
Nov10-04, 04:56 PM
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!

Hurkyl
Nov10-04, 05:01 PM
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)

dav2008
Nov10-04, 05:22 PM
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).

Nylex
Nov10-04, 05:28 PM
Random class (http://java.sun.com/j2se/1.5.0/docs/api/java/util/Random.html) from the API specification.

xLaser
Nov10-04, 10:03 PM
got it, thx dudes.