Advertisement
alicemiriel

Untitled

Mar 2nd, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. package pl.sda.metody.zadania;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class CzyJestPodzielnePrzez {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         System.out.println("Podaj liczbe a powiem Ci czy jest podzielna przez 3 lub 5");
  9.         int parametr = scanner.nextInt();
  10.  
  11.         podzielnaPrzez(parametr);
  12.         System.out.println("Podaj dzielnik, przez ktory chcesz sprawdzic");
  13.         int dzielnik = scanner.nextInt();
  14.  
  15.         podzielnaPrzezTwojaWartosc(parametr, dzielnik);
  16.     }
  17.  
  18.  
  19.     public static void podzielnaPrzez(int number) {
  20.         if ((number % 3 == 0)) {
  21.             System.out.println("Twoja liczba jest podzielna przez 3");
  22.         } else if (number % 5 == 0) {
  23.             System.out.println("Twoja liczba jest podzielna przez 5");
  24.         } else {
  25.             System.out.println("Twoja liczba jest niepodzielna ani przez 5 ani przez 3!");
  26.         }
  27.     }
  28.  
  29.     public static void podzielnaPrzezTwojaWartosc(int number, int dzielnik) {
  30.         if (number % dzielnik == 0) {
  31.             System.out.println("Twoja liczba jest podzielna przez Twรณj dzielnik!");
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement