Advertisement
CR7CR7

12.EvenNumber

Sep 17th, 2022
942
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P12EvenNumber {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int num = Integer.parseInt(scanner.nextLine());
  8.  
  9.         while (num % 2 != 0) {
  10.             System.out.println("Please write an even number.");
  11.  
  12.             num = Integer.parseInt(scanner.nextLine());
  13.         }
  14.  
  15.         System.out.printf("The number is: %d", Math.abs(num));
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement