Given the code below, why would the compiler complain at line 5 even though coupon, offset, and base have been initialized within the if statement? Since 'percent' variable is given a default value of 0.0, the if statement will run and set those values.
public class Discounter {
static double percent; //1
int offset = 10, base= 50; //2
public static double calc(double value) {
var coupon, offset, base; //3
if(percent <10){ //4
coupon = 15;
offset = 20;
base = 10;
}
return coupon*offset*base*value/100; //5
}
public static void main(String[] args) {
System.out.println(calc(100));
} }