What's wrong with my code?
I just got to switches on the java tutorial on sololearn and I tried to make a calculator using everything I learned but apparently I'm using switches wrong and I don't know what it is. I also want to know if theres a way I can make a calculator like this but with smaller lines of code. import java.util.Scanner; public class UpdatedCalculator { public static void main(String[] args) { double fnum,snum,answer; answer = 0; String operator; Scanner s = new Scanner(System.in); System.out.println("Enter First Number:\t"); fnum = s.nextDouble(); System.out.println("\nEnter Second Number:\t"); snum = s.nextDouble(); System.out.println("Choose your operator:"); System.out.println("\nAddition(a) \n\nSubtraction(b) \n\nDivision(c) \n\nMultiplication(d)"); operator = s.nextLine(); switch (answer) { case a: answer = fnum + snum; break; case b: answer = fnum - snum; break; case c: answer = fnum/snum; break; case d: answer = fnum * snum; break; default: System.out.println("No Such Operation."); } System.out.println(" "); if(operator.equals(a) || operator.equals(b) || operator.equals(c) || operator.equals(d)) { System.out.println("Answer: " + answer); }else { System.out.println("\n\nError! \n\nError! \n\nError!"); } } }