Advertisement
Spocoman

11. Even Number

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