I am creating a new class the calculates random integers in simplistic mathematical operations for school. Bellow I have copy/paste my code from JGRASP, I have commented on the two portions that are not performing correctly. The first error message in correlation to the first portion that I commented on as being a mistake states the following:
PrintingIntCalculator.java:4: error: illegal start of type
import java.until.Random;
^
PrintingIntCalculator.java:4: error: ';' expected
import java.until.Random;
^
PrintingIntCalculator.java:4: error: illegal start of type
import java.until.Random;
^
PrintingIntCalculator.java:4: error: ';' expected
import java.until.Random;
^
PrintingIntCalculator.java:4: error: <identifier> expected
import java.until.Random;
^
The second portion in which I commented on (at the end of my code) states the following error message:
PrintingIntCalculator.java:34: error: ';' expected
total = ran.nextInt(b-a+1)+a)
^
Both of these are suppose to tell the class that it needs to generate a random number. Could someone please help me correct these problems. It is greatly appreciated.
Thank you so much in advance
public class PrintingIntCalculator {
//This part is wrong:
import java.until.Random;
public PrintingIntCalculator(){}
private int total = 0;
private int a = 0;
private int b = 0;
public int add(int a, int b){
total = a + b;
return (total);
}
public int subtract(int a, int b){
total = a - b;
return (total);
}
public int multiply(int a, int b){
total = a * b;
return (total);
}
public int divide(int a, int b){
total = a / b;
return (total);
}
public int remainder(int a, int b){
total = a % b;
return (total);
}
//This part is wrong:
public int random(int a, int b){
Random ran = new Random ();
total = ran.nextInt(b-a+1)+a)
return (total);
}
}