I want my variable i to have the value of these fractions depending on a random number. However, when I print out i, it displays 1.0. Why is that and how can I solve this issue?
public class Musik{
public static void main(String[] args){
Interval();
System.out.println(Interval());
}
public static double Interval(){
int a = (int)(Math.random() * 5);
System.out.println(a);
double i = 0;
switch (a) {
case 0 :
i = 2;
break;
case 1 :
i = 3/2;
break;
case 2 :
i = 4/3;
break;
case 3 :
i = 5/4;
break;
case 4 :
i = 9/8;
break;
}
return i;
}
}