Java:
public class Calculator2 {
public static void main(String[] args) {
{
double ersteZahl = Double.parseDouble(args[0]);
double zweiteZahl = Double.parseDouble(args[2]);
char operation = args[1].charAt(0);
switch (operation) {
case '+':
System.out.println( ersteZahl + " + " + zweiteZahl + " = " + (ersteZahl + zweiteZahl));
break;
case '-':
System.out.println( ersteZahl + " - " + zweiteZahl + " = " + (ersteZahl - zweiteZahl));
break;
case '*':
System.out.println( ersteZahl + " * " + zweiteZahl + " = " + (ersteZahl * zweiteZahl));
break;
case '/':
System.out.println( ersteZahl + " / " + zweiteZahl + " = " + (ersteZahl / zweiteZahl));
break;
default:
System.out.println("Ungültige Operation");
break;
}
}
}
}