Advertisement
myrdok123

11. Even Number

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