Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.sda.metody.zadania;
- import java.util.Scanner;
- public class CzyJestPodzielnePrzez {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Podaj liczbe a powiem Ci czy jest podzielna przez 3 lub 5");
- int parametr = scanner.nextInt();
- podzielnaPrzez(parametr);
- System.out.println("Podaj dzielnik, przez ktory chcesz sprawdzic");
- int dzielnik = scanner.nextInt();
- podzielnaPrzezTwojaWartosc(parametr, dzielnik);
- }
- public static void podzielnaPrzez(int number) {
- if ((number % 3 == 0)) {
- System.out.println("Twoja liczba jest podzielna przez 3");
- } else if (number % 5 == 0) {
- System.out.println("Twoja liczba jest podzielna przez 5");
- } else {
- System.out.println("Twoja liczba jest niepodzielna ani przez 5 ani przez 3!");
- }
- }
- public static void podzielnaPrzezTwojaWartosc(int number, int dzielnik) {
- if (number % dzielnik == 0) {
- System.out.println("Twoja liczba jest podzielna przez Twรณj dzielnik!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement