Raizekas

Untitled

Mar 17th, 2021
31
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package skaiciavimoobjektai;
  2.  
  3. public class Kalkuliatorius
  4. {
  5. public int dauginti(int a, int b)
  6. {
  7. int daugyba = a * b;
  8. return daugyba;
  9. }
  10.  
  11. public short daugintiShort(short a, short b)
  12. {
  13. short daugyba = (short) (a * b);
  14. return daugyba;
  15. }
  16.  
  17.  
  18. public int dalinti(int a, int b)
  19. {
  20. try
  21. {
  22. int dalyba = a / b;
  23. return dalyba;
  24. }
  25. catch (ArithmeticException e)
  26. {
  27. System.out.println("Negalima dalinti is nulio");
  28. return -1;
  29. }
  30. }
  31.  
  32. public int sudetis(int a, int b)
  33. {
  34. return a + b;
  35. }
  36.  
  37.  
  38. public int atimtis(int a, int b)
  39. {
  40. return a - b;
  41. }
  42. }
  43.  
RAW Paste Data