Advertisement
Guest User

Untitled

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