Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class trzydziescidziewiec {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.println("Wprowadz argument 1: ");
- int x = sc.nextInt();
- System.out.println("Wprowadz argument 2: ");
- int y = sc.nextInt();
- System.out.println("Wprowadz operator: ");
- char z = sc.next().charAt(0);
- switch(z){
- case '+' : System.out.println(" "+x+" + "+y+" = "+x+y+" ");break;
- case '-' : System.out.println(" "+x+" - "+y+" = "+x-y+" ");break;
- case '*' : System.out.println(" "+x+" * "+y+" = "+x*y+" ");break;
- case '/' :
- if(y==0){
- System.out.println("Dzielenie przez zero nie dozwolone");
- }else{
- System.out.println(" "+x+" / "+y+" = "+x/y+" "); }break;
- default : System.out.println("Nie prawidłowy znak");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement