SonicDesu

Untitled

Jun 1st, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MyFirstJavaApplication {
  4.     public static void main(String[] args) {
  5.         double x,y;
  6.         Scanner scanner = new Scanner(System.in);
  7.         System.out.println("Witaj w kalkulatorze!");
  8.         System.out.println("Wprowadz x:");
  9.         x = scanner.nextDouble();
  10.         System.out.println("Wprowadz y:");
  11.         y = scanner.nextDouble();
  12.         System.out.println("Jaką operację chcesz wykonać? X [] Y\nWybierz jedną z czterech dostępnych: /,*,+,-");
  13.         char operacja;
  14.         System.out.println("\nWprowadz znak: ");
  15.         operacja = scanner.next().charAt(0);
  16.  
  17.  
  18.         scanner.close();
  19.         System.out.println("TWÓJ WYNIK TO:");
  20.         if(operacja == '-'){
  21.             System.out.println(x-y);
  22.         }
  23.         else if(operacja=='/'){
  24.             System.out.println(x/y);
  25.         }
  26.         else if(operacja =='*'){
  27.             System.out.println(x*y);
  28.         }
  29.         else if(operacja=='+'){
  30.             System.out.println(x+y);
  31.         }
  32.  
  33.  
  34.  
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment