I just started with java and its doing realy good till now. But now i startet coding a little bit on my own. dont get the Problem here:
import java.util.Scanner;
public class Taschenrechner {
public static void main(String[] args) {
System.out.println ("Mein erster Java Taschenrechner");
Scanner scan = new Scanner (System.in);
System.out.println ("Welche Operation ? Möglich sind + - x /");
String operation = scan.nextLine ();
System.out.println ("Erste Zahl ?");
int input1 = scan.nextInt ();
System.out.println ("Zweite Zahl ?");
int input2 = scan.nextInt ();
int output = 0;
if (operation == "+") {
output = input1 + input2;
}
else if (operation == "-") {
output = input1 - input2;
}
else if (operation == "x") {
output = input1 * input2;
}
else if (operation == "/") {
output = input1 / input2;
}
System.out.println ("Das Ergebnis ist: " + output);
}
}
The variable output stays 0 and dont change
By the way...have i postet the code sampe the right way ?