Moin Moin,
Hab in der Schule n Taschenrechner gemacht der mir das Ergebnis nicht ausgibt!
Er kommt nicht in die "if"-entscheidung rein!!
Wieso ?
mfg und Hoffnung auf baldige Antwort
wiesner95
Hab in der Schule n Taschenrechner gemacht der mir das Ergebnis nicht ausgibt!
Java:
import java.util.*;
public class Taschenrechner{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
System.out.print("Erste Zahl: ");
String z1=sc.next();
System.out.print("Rechenzeichen: ");
String r=sc.next();
System.out.print("Zweite Zahl: ");
String z2=sc.next();
Integer zahl1=new Integer (z1);
int a=zahl1.intValue();
Integer zahl2=new Integer (z2);
int b=zahl2.intValue();
int x = a+b;
int y = a-b;
int z = a*b;
int v = a/b;
if(r==("+")){
System.out.println(a+"+"+b+"="+x);
}
if(r==("-")){
System.out.println(a+"-"+b+"="+y);
}
if(r==("*")){
System.out.println(a+"*"+b+"="+z);
}
if(r==("/")){
System.out.println(a+"/"+b+"="+v);
}
}
}
Er kommt nicht in die "if"-entscheidung rein!!
Wieso ?
mfg und Hoffnung auf baldige Antwort
wiesner95
Zuletzt bearbeitet von einem Moderator: