Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication2;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class JavaApplication2 {
- public static void main(String[] args) throws IOException
- {
- InputStreamReader input = new InputStreamReader(System.in);
- BufferedReader tastiera = new BufferedReader(input);
- int a = 0;
- int b = 0,d=0;
- System.out.println("Che operazione vuoi effettuare : \n 0=Addizione \n 1=Sottrazione \n 2=Moltiplicazione \n 3=Divisione \n 4=Somma di due quadrati \n 5=Differenza tra il massimo valore e il minimo di due quadrati \n");
- try
- { String am = tastiera.readLine();
- b=Integer.valueOf(am).intValue();
- }
- catch(Exception z)
- { System.out.println("Error");
- }
- switch(b)
- { case 0 :
- System.out.println("Inserisci Numero");
- try
- { String ax = tastiera.readLine();
- a=Integer.valueOf(ax).intValue();
- String ab = tastiera.readLine();
- b=Integer.valueOf(ab).intValue();
- }
- catch(Exception z)
- { System.out.println("Error");
- }
- d=d+a;
- break;
- case 1:
- System.out.println("Inserisci Numeri");
- try
- { String ax = tastiera.readLine();
- a=Integer.valueOf(ax).intValue();
- String ab = tastiera.readLine();
- b=Integer.valueOf(ab).intValue();
- }
- catch(Exception z)
- { System.out.println("Error");
- }
- d=a-b;
- break;
- case 2:
- System.out.println("Inserisci Numeri");
- try
- { String ax = tastiera.readLine();
- a=Integer.valueOf(ax).intValue();
- String ab = tastiera.readLine();
- b=Integer.valueOf(ab).intValue();
- }
- catch(Exception z)
- { System.out.println("Error");
- }
- d=a*b;
- break;
- case 3:
- System.out.println("Inserisci Numeri");
- try
- { String ax = tastiera.readLine();
- a=Integer.valueOf(ax).intValue();
- String ab = tastiera.readLine();
- b=Integer.valueOf(ab).intValue();
- }
- catch(Exception z)
- { System.out.println("Error");
- }
- d=a/b;
- break;
- case 4:
- System.out.println("Inserisci Numeri");
- try
- { String ax = tastiera.readLine();
- a=Integer.valueOf(ax).intValue();
- String ab = tastiera.readLine();
- b=Integer.valueOf(ab).intValue();
- }
- catch(Exception z)
- { System.out.println("Error");
- }
- d=(a*a)+(b*b);
- break;
- case 5:
- System.out.println("Inserisci Numeri");
- try
- { String ax = tastiera.readLine();
- a=Integer.valueOf(ax).intValue();
- String ab = tastiera.readLine();
- b=Integer.valueOf(ab).intValue();
- }
- catch(Exception z)
- { System.out.println("Error");
- }
- a*=a;
- b*=b;
- if(a>b)
- {d=a-b;
- }else
- {d=b-a;
- }
- break;
- }
- System.out.println("Risultato "+d);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement