Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Java Homework, a little help.

  1. Nov 10, 2004 #1
    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!
  2. jcsd
  3. Nov 10, 2004 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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)
  4. Nov 10, 2004 #3


    User Avatar
    Gold Member

    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).
  5. Nov 10, 2004 #4
  6. Nov 10, 2004 #5
    got it, thx dudes.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook