Question: Java - Eclipse Create a class named AdditionProblem with the following definition: public class AdditionProblem { private int x,y,answer; public AdditionProblem() { x = (int)(10
Java - Eclipse
Create a class named AdditionProblem with the following definition:
public class AdditionProblem {
private int x,y,answer; public AdditionProblem() { x = (int)(10 + 40*Math.random()); y = (int)(30 * Math.random()); answer = x + y; } public String getProblem() { return "Compute the sum: " + x + " + " + y; } public int getAnswer() { return answer; } }
Now, change the main() routine so that it creates an AdditionProblem, displays to the user the problem returned by the getProblem() method, reads an answer from the user, and checks to see whether the answer entered by the user agrees with the correct answer as returned by getAnswer().
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
