Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Rechner {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- double zahl1;
- double zahl2;
- char operator;
- Scanner scn = new Scanner(System.in);
- System.out.println("Gib eine zahl ein: ");
- zahl1 = scn.nextInt();
- System.out.println("Gib einen Operatoren ein: ");
- operator = scn.next().charAt(0);
- System.out.println("Gib die zweite Zahl ein:");
- zahl2 = scn.nextInt();
- if (operator == '+'){
- System.out.println(zahl1 + zahl2);
- } else if (operator == '-') {
- System.out.println(zahl1 - zahl2);
- } else if (operator == '*') {
- System.out.println(zahl1 - zahl2);
- } else if (operator == '/') {
- System.out.println(zahl1 / zahl2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement