i failed and now i need to take a resit exam. This question was on the final exam and i feel like similar one will come on resit exam. We cant use our computers on the exam we have to write everything on paper so that was big issue i couldnt understand if im doing it wrong or right. Please be kind while answering because im new at java and i dont want to lose my hope i need to pass.
(i cant remember %100 but this was the main idea)
Q: In this question write two methods. First method should take two random variables. And second method should compare those two random variables and gives the result as higher one.
My solution:
import acm.program.*;
import acm.util.RandomGenerator;
public class RandomGenereratorBaby extends ConsoleProgram {
public RandomGenerator rgen = RandomGenerator.getInstance();{
int x = rgen.nextInt(0,9);
int y = rgen.nextInt(0,9);
}
public char BiggerOneWins (int x, int y){
if(x>=y){
return (char) (x) ;
}else{
return (char) (y);
}
}}
Please help me.