Advertisement
Guest User

cycki

a guest
Oct 30th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. package smiesznanazwa;
  4.  
  5. public class Smiesznanazwa
  6. {
  7.  
  8. public static void main(String[] args)
  9. {
  10. Scanner S = new Scanner(System.in);
  11. int liczba1 = S.nextInt();
  12. if(liczba1 <= 0)
  13. {
  14. System.out.println("Wprowadzona liczba musi byc dodatnia, sprobuj jeszcze raz :)");
  15. liczba1 = S.nextInt();
  16. }
  17.  
  18. int liczba2 = S.nextInt();
  19. if(liczba2 <= 0)
  20. {
  21. System.out.println("Wprowadzona liczba musi byc dodatnia, sprobuj jeszcze raz :)");
  22. liczba2 = S.nextInt();
  23. }
  24.  
  25. System.out.println("Wprowadzone liczby: "+liczba1+", "+liczba2);
  26.  
  27. if(liczba1 < liczba2)
  28. {
  29. if(liczba2 % liczba1 == 0)
  30. {
  31. System.out.println("Pierwsza liczba jest dzielnikiem drugiej");
  32. }
  33. } else if(liczba2 < liczba1) {
  34. if(liczba1 % liczba2 == 0)
  35. {
  36. System.out.println("Druga liczba jest dzielnikiem pierwszej");
  37. };
  38. } else if(liczba1 == liczba2) {
  39. System.out.println("Liczby sa takie same, wiec sa swoimi dzielnikami");
  40. };
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement