fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. static boolean isValidPesel(String pesel) {
  8. return isValidLength(pesel);
  9. }
  10.  
  11. private static boolean isValidLength(String pesel) {
  12. return pesel != null && pesel.length() == 11;
  13. }
  14.  
  15. public static void main (String[] args) throws java.lang.Exception
  16. {
  17. System.out.println("Podaj nr PESEL: ");
  18. Scanner scanner = new Scanner(System.in);
  19. String inputString = scanner.nextLine();
  20. if (isValidPesel(inputString)) {
  21. System.out.println("Poprawny!");
  22. } else {
  23. System.out.println("Niepoprawny!");
  24. }
  25. }
  26. }
Success #stdin #stdout 0.13s 35132KB
stdin
71091032849
stdout
Podaj nr PESEL: 
Poprawny!