Advertisement
veronikaaa86

12. Even Number

Sep 14th, 2022
1,109
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.  
  11.         while (num % 2 != 0) {
  12.             System.out.println("Please write an even number.");
  13.  
  14.             num = Integer.parseInt(scanner.nextLine());
  15.         }
  16.  
  17.         System.out.printf("The number is: %d", Math.abs(num));
  18.     }
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement