Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package softuniada;
- import java.util.*;
- public class Pr01Digitivision {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int firstInt = Integer.parseInt(scanner.nextLine());
- int secondInt = Integer.parseInt(scanner.nextLine());
- int thirdInt = Integer.parseInt(scanner.nextLine());
- int sum = sum(firstInt, secondInt, thirdInt);
- if (firstInt == 0 && secondInt == 0 && thirdInt == 0) {
- System.out.println("No digitivision possible!");
- return;
- }
- boolean hasDigitivision = false;
- for (int i = 0; i < 6; i++) {
- int currentNumber = Integer.parseInt("" + firstInt + secondInt + thirdInt);
- if (String.valueOf(currentNumber).startsWith("0")) {
- continue;
- }
- if (currentNumber % sum == 0) {
- hasDigitivision = true;
- break;
- }
- int temp = firstInt;
- firstInt = secondInt;
- secondInt = thirdInt;
- thirdInt = temp;
- }
- if (hasDigitivision) {
- System.out.println("Digitivision successful!");
- } else {
- System.out.println("No digitivision possible!");
- }
- }
- private static int sum(int firstInt, int secondInt, int thirdInt) {
- return firstInt + secondInt + thirdInt;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement