Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MyFirstJavaApplication {
- public static void main(String[] args) {
- double x,y;
- Scanner scanner = new Scanner(System.in);
- System.out.println("Witaj w kalkulatorze!");
- System.out.println("Wprowadz x:");
- x = scanner.nextDouble();
- System.out.println("Wprowadz y:");
- y = scanner.nextDouble();
- System.out.println("Jaką operację chcesz wykonać? X [] Y\nWybierz jedną z czterech dostępnych: /,*,+,-");
- char operacja;
- System.out.println("\nWprowadz znak: ");
- operacja = scanner.next().charAt(0);
- scanner.close();
- System.out.println("TWÓJ WYNIK TO:");
- if(operacja == '-'){
- System.out.println(x-y);
- }
- else if(operacja=='/'){
- System.out.println(x/y);
- }
- else if(operacja =='*'){
- System.out.println(x*y);
- }
- else if(operacja=='+'){
- System.out.println(x+y);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment