JAVA .. ECLIPSE .. RANDOM NUMBER GENETATOR NEED TWO CLASSES ONE FOR ALL THE METH
ID: 3603329 • Letter: J
Question
JAVA .. ECLIPSE .. RANDOM NUMBER GENETATOR NEED TWO CLASSES ONE FOR ALL THE METHOD AND OTHER FOR EXECUTION>
addition -two operands, both in the range 0 -12•subtraction -two operands, the first in the range 6-12 and the second less than or equal to the first –for example (12-10, 6-2, etc.)•Rule: if the first operand is 7, for example, the second operand must range from 0 to 7.•Your task is to write a programmer defined class that contains a randomly generated addition or subtraction problem A toStringmethod that returns a String containing the question (but not the answer). The format should be operand1, a space, operator, a space, operand2, a space and an equal sign. A determineAnswermethod that calculates the answer to the question and returns the answer (an integer). The answer should notbe stored as an instance variable.
Once you have the instance variables, accessormethods, constructor, toString, and determineAnswermethods written, test your code in the application class to make sure it works properly.
Explanation / Answer
public int random(int i){ Random randnum = new Random(); randnum.setSeed(123456789); return randnum.nextInt(i); } public class Numbers { Random randnum; public Numbers() { randnum = new Random(); randnum.setSeed(123456789); } public int random(int i){ return randnum.nextInt(i); } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.