Master Java Homework: Learn to Create Random Math Addition Questions with Ease!

  • Thread starter Thread starter xLaser
  • Start date Start date
  • Tags Tags
    Homework Java
AI Thread Summary
To create a program that displays a random math addition question in Java, users need to utilize the Random class to generate two random integers. The nextInt(max) method from the Random class can be used to select a random number within a specified range. The program should then prompt the user for the sum of these two numbers and check if their answer is correct. Understanding how to implement this functionality is essential for completing the assignment. Mastering these concepts will enhance programming skills in Java.
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).
 
got it, thanks dudes.
 
Kindly see the attached pdf. My attempt to solve it, is in it. I'm wondering if my solution is right. My idea is this: At any point of time, the ball may be assumed to be at an incline which is at an angle of θ(kindly see both the pics in the pdf file). The value of θ will continuously change and so will the value of friction. I'm not able to figure out, why my solution is wrong, if it is wrong .
TL;DR Summary: I came across this question from a Sri Lankan A-level textbook. Question - An ice cube with a length of 10 cm is immersed in water at 0 °C. An observer observes the ice cube from the water, and it seems to be 7.75 cm long. If the refractive index of water is 4/3, find the height of the ice cube immersed in the water. I could not understand how the apparent height of the ice cube in the water depends on the height of the ice cube immersed in the water. Does anyone have an...
Back
Top