Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Rechner {
  4.  
  5.     public static void main(String[] args) {
  6.         // TODO Auto-generated method stub
  7.  
  8.         double zahl1;
  9.         double zahl2;
  10.         char operator;
  11.        
  12.         Scanner scn = new Scanner(System.in);
  13.        
  14.         System.out.println("Gib eine zahl ein: ");
  15.         zahl1 = scn.nextInt();
  16.        
  17.         System.out.println("Gib einen Operatoren ein: ");
  18.         operator = scn.next().charAt(0);
  19.        
  20.         System.out.println("Gib die zweite Zahl ein:");
  21.         zahl2 = scn.nextInt();
  22.        
  23.         if (operator == '+'){
  24.             System.out.println(zahl1 + zahl2);
  25.         } else if (operator == '-') {
  26.             System.out.println(zahl1 - zahl2);
  27.         } else if (operator == '*') {
  28.             System.out.println(zahl1 - zahl2);
  29.         } else if (operator == '/') {
  30.             System.out.println(zahl1 / zahl2);
  31.         }
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement