Use this exercise to test your code that you wrote in the previous exercise. Problem Class In this exercise, you are going to create the Problem class. The Problem class is used to help simulate a math fact, for example: 2 + 5 = Your class needs to contain two constructors, one that takes String, int, int that represents the operator sign(+, -, *, or /), the minimum, and maximum values for the number range, and a second constructor that takes only a String that represents the operator sign. For the second constructor, the minimum should default to zero and the maximum to ten. Your Problem object should generate 2 random integers between the minimum and maximum values (inclusively). Each Problem object should only have one set of numbers that do not change. While you may include additional helper methods, two methods need to be available to the user. The first is the answer method that should return a double that represents the answer to the problem. The second is the toString that should return a String that represents the problem. The format shoule be: number operator number equal sign For example: 5 - 3 = 8 / 2 = public class ProblemTester { public static void main(String[] args) { // Test your code here } } also needs a problem class
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Use this exercise to test your code that you wrote in the previous exercise.
Problem Class
In this exercise, you are going to create the Problem class. The Problem class is used to help simulate a math fact, for example:
2 + 5 =Your class needs to contain two constructors, one that takes String, int, int that represents the operator sign(+, -, *, or /), the minimum, and maximum values for the number range, and a second constructor that takes only a String that represents the operator sign. For the second constructor, the minimum should default to zero and the maximum to ten.
Your Problem object should generate 2 random integers between the minimum and maximum values (inclusively). Each Problem object should only have one set of numbers that do not change.
While you may include additional helper methods, two methods need to be available to the user. The first is the answer method that should return a double that represents the answer to the problem.
The second is the toString that should return a String that represents the problem. The format shoule be:
number operator number equal sign
For example:
5 - 3 = 8 / 2 ={
public static void main(String[] args)
{
// Test your code here
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images