Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Klasascanner extends IllegalArgumentException {
  3. public static double Dodawanie(double a,double b)
  4. {
  5. return a+b;
  6.  
  7. }
  8. public static double Odejmowanie(double a,double b)
  9. {
  10. return a-b;
  11.  
  12. }
  13. public static double Mnozenie(double a,double b)
  14. {
  15. return a*b;
  16.  
  17. }
  18. public static double Dzielenie(double a,double b)
  19. {
  20. if (b==0)
  21. {
  22. throw new IllegalArgumentException("b=0,cannot divide");
  23. }
  24. return a/b;
  25.  
  26. }
  27.  
  28. public static void main(String[] args)
  29. {
  30. double a , b;
  31.  
  32.  
  33. Scanner sc = new Scanner(System.in);
  34.  
  35. a=Double.parseDouble(sc.nextLine());
  36. b=Double.parseDouble(sc.nextLine());
  37.  
  38.  
  39.  
  40. System.out.println("Wynik dodawania"+Dodawanie(a,b));
  41. System.out.println("Wynik odejmowania"+Odejmowanie(a,b));
  42. System.out.println("Wynik mnożenia"+Mnozenie(a,b));
  43. System.out.println("Wynik dzielenia"+Dzielenie(a,b));
  44.  
  45. }
  46.  
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement