Advertisement
Guest User

Untitled

a guest
Nov 27th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1.  
  2. package javaapplication2;
  3.  
  4. import java.io.BufferedReader;
  5. import java.io.IOException;
  6. import java.io.InputStreamReader;
  7.  
  8. public class JavaApplication2 {
  9.  
  10.  
  11. public static void main(String[] args) throws IOException
  12. {
  13. InputStreamReader input = new InputStreamReader(System.in);
  14. BufferedReader tastiera = new BufferedReader(input);
  15. int a = 0;
  16. int b = 0,d=0;
  17. 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");
  18. try
  19. { String am = tastiera.readLine();
  20. b=Integer.valueOf(am).intValue();
  21. }
  22. catch(Exception z)
  23. { System.out.println("Error");
  24. }
  25. switch(b)
  26. { case 0 :
  27.  
  28. System.out.println("Inserisci Numero");
  29. try
  30. { String ax = tastiera.readLine();
  31. a=Integer.valueOf(ax).intValue();
  32. String ab = tastiera.readLine();
  33. b=Integer.valueOf(ab).intValue();
  34. }
  35. catch(Exception z)
  36. { System.out.println("Error");
  37. }
  38. d=d+a;
  39.  
  40. break;
  41. case 1:
  42.  
  43.  
  44. System.out.println("Inserisci Numeri");
  45. try
  46. { String ax = tastiera.readLine();
  47. a=Integer.valueOf(ax).intValue();
  48. String ab = tastiera.readLine();
  49. b=Integer.valueOf(ab).intValue();
  50. }
  51. catch(Exception z)
  52. { System.out.println("Error");
  53. }
  54.  
  55. d=a-b;
  56. break;
  57.  
  58. case 2:
  59.  
  60.  
  61. System.out.println("Inserisci Numeri");
  62. try
  63. { String ax = tastiera.readLine();
  64. a=Integer.valueOf(ax).intValue();
  65. String ab = tastiera.readLine();
  66. b=Integer.valueOf(ab).intValue();
  67. }
  68. catch(Exception z)
  69. { System.out.println("Error");
  70. }
  71.  
  72. d=a*b;
  73. break;
  74. case 3:
  75.  
  76.  
  77. System.out.println("Inserisci Numeri");
  78. try
  79. { String ax = tastiera.readLine();
  80. a=Integer.valueOf(ax).intValue();
  81. String ab = tastiera.readLine();
  82. b=Integer.valueOf(ab).intValue();
  83. }
  84. catch(Exception z)
  85. { System.out.println("Error");
  86. }
  87.  
  88. d=a/b;
  89. break;
  90. case 4:
  91.  
  92.  
  93. System.out.println("Inserisci Numeri");
  94. try
  95. { String ax = tastiera.readLine();
  96. a=Integer.valueOf(ax).intValue();
  97. String ab = tastiera.readLine();
  98. b=Integer.valueOf(ab).intValue();
  99. }
  100. catch(Exception z)
  101. { System.out.println("Error");
  102. }
  103.  
  104. d=(a*a)+(b*b);
  105. break;
  106. case 5:
  107.  
  108.  
  109. System.out.println("Inserisci Numeri");
  110. try
  111. { String ax = tastiera.readLine();
  112. a=Integer.valueOf(ax).intValue();
  113. String ab = tastiera.readLine();
  114. b=Integer.valueOf(ab).intValue();
  115. }
  116. catch(Exception z)
  117. { System.out.println("Error");
  118. }
  119.  
  120. a*=a;
  121. b*=b;
  122. if(a>b)
  123. {d=a-b;
  124. }else
  125. {d=b-a;
  126. }
  127. break;
  128.  
  129.  
  130. }
  131. System.out.println("Risultato "+d);
  132. }
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement