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.
 
I multiplied the values first without the error limit. Got 19.38. rounded it off to 2 significant figures since the given data has 2 significant figures. So = 19. For error I used the above formula. It comes out about 1.48. Now my question is. Should I write the answer as 19±1.5 (rounding 1.48 to 2 significant figures) OR should I write it as 19±1. So in short, should the error have same number of significant figures as the mean value or should it have the same number of decimal places as...
Thread 'A cylinder connected to a hanging mass'
Let's declare that for the cylinder, mass = M = 10 kg Radius = R = 4 m For the wall and the floor, Friction coeff = ##\mu## = 0.5 For the hanging mass, mass = m = 11 kg First, we divide the force according to their respective plane (x and y thing, correct me if I'm wrong) and according to which, cylinder or the hanging mass, they're working on. Force on the hanging mass $$mg - T = ma$$ Force(Cylinder) on y $$N_f + f_w - Mg = 0$$ Force(Cylinder) on x $$T + f_f - N_w = Ma$$ There's also...
Back
Top