I am having trouble with my switches.
I am very new to java and I am trying to make a very simple calculator. I have written my code from scratch but I can't get my switch to work. It keeps only calculating case 3 no matter what I tell it to do. Could anyone help me to realise where I have gone wrong?
Here is my code
Code:
import java.util.Scanner;
public class Cal
{
public static void main(String[] args)
{
System.out.println("Enter first number");
Scanner sc = new Scanner(System.in);
double a = sc.nextDouble();
System.out.println("Enter second number");
Scanner dc = new Scanner(System.in);
double b = dc.nextDouble();
System.out.println("Enter + or - or /");
Scanner ss1 = new Scanner(System.in);
String s1 = ss1.next();
int switchy;
if(s1.equals("/"));
switchy=1;
if(s1.equals("-"));
switchy=2;
if(s1.equals("+"));
switchy=3;
switch (switchy) {
case 1: double h = a/b;
System.out.println(h);
break;
case 2: h = a-b;
System.out.println(h);
break;
case 3: h = a+b;
System.out.println(h);
break;
}
}
}
Thanks in advance.