Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class trzydziescidziewiec {
  4.        
  5.    
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.        System.out.println("Wprowadz argument 1: ");
  9.        int x = sc.nextInt();
  10.        System.out.println("Wprowadz argument 2: ");
  11.        int y = sc.nextInt();
  12.        System.out.println("Wprowadz operator: ");
  13.        char z = sc.next().charAt(0);
  14.        
  15.        switch(z){
  16.         case '+' : System.out.println(" "+x+" + "+y+" = "+x+y+" ");break;
  17.         case '-' : System.out.println(" "+x+" - "+y+" = "+x-y+" ");break;
  18.         case '*' : System.out.println(" "+x+" * "+y+" = "+x*y+" ");break;
  19.         case '/' :
  20.             if(y==0){
  21.                 System.out.println("Dzielenie przez zero nie dozwolone");
  22.             }else{
  23.            
  24.             System.out.println(" "+x+" / "+y+" = "+x/y+" "); }break;
  25.        
  26.         default : System.out.println("Nie prawidłowy znak");
  27.        }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement