Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- /**
- * Zad 1. Wypisanie kod�w pocztowych i miast w formacie xx xxx Miasto, z formatu
- * xx-xxx Miasto. Miasto rozpoczyna si� wielk� liter�, reszta ma�a
- *
- * Zad 2. Wykoanie sumy dochod�w
- *
- * Zad 3. Wykonanie sumy podanych liczb
- * @author Damian
- *
- */
- public class Log {
- // wypisanie samych danych o dochodach
- // wypisanie kodow pocztowych w formacie xx xxx, z xx-xxx np.10-100 na 10
- // 100
- // konwersja liczb zapisywanych w pliku do formatu zmiennoprzecinkowego, np.
- // 10
- // 10 = 10.10
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Prosze o podanie hasla");
- String haslo = scanner.nextLine();
- test1(haslo);
- if(test1(haslo) == true) {
- System.out.println("Podane haslo jest poprawne");
- }
- else {
- System.out.println("Podane haslo jest niepoprawne");
- }
- }
- private static boolean test1(String a) {
- String pattern = "^[0-9]{2}[a-zA-Z.]{2}\\s[a-zA-Z.]{3,}[0-9]{2}$";
- Pattern r = Pattern.compile(pattern);
- Matcher m = r.matcher(a);
- boolean test= m.matches() ;
- if( test == true) return true;
- else return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement