Advertisement
veronikaaa86

12. Even Number

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