Guest User

Untitled

a guest
Feb 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. package javaapplication1;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class JavaApplication1 {
  6.  
  7. public static void main(String[] args) {
  8. Scanner sc = new Scanner(System.in);
  9. boolean charMai = false;
  10. int num2 = 0;
  11. do {
  12. System.out.print("Input even number :");
  13. String inputString = sc.next();
  14. charMai = false;
  15. for (char ch : inputString.toCharArray()) {
  16. if (ch < '0' || ch > '9') {
  17. charMai = true;
  18. break;
  19. }
  20. }
  21. if (!charMai) {
  22. num2 = Integer.parseInt(inputString);
  23. }
  24. } while (!charMai && num2 % 2 == 0);
  25. System.out.println("Program shutdown");
  26.  
  27. }
  28. }
Add Comment
Please, Sign In to add comment