I recently encountered a situation that is somewhat similar to this.
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), ... , g = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt(), z;
z = x * y;
switch (z) {
case a : //print something
break;
.
.
.
case g : //print something
break;
default : //print something
break;
}
I encountered an error for all the case labels. I checked through some tutorials and have not got all the answers. I need to know if I can make it work with switch statement since it is a constraint I must use.