Advertisement
veronikaaa86

12. Even Number

May 18th, 2022
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 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. num = Integer.parseInt(scanner.nextLine());
  14.  
  15. // if (num % 2 == 0) {
  16. // System.out.printf("The number is: %d", Math.abs(num));
  17. // break;
  18. // } else {
  19. // System.out.println("Please write an even number.");
  20. // num = Integer.parseInt(scanner.nextLine());
  21. // }
  22. }
  23. System.out.printf("The number is: %d", Math.abs(num));
  24. }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement