Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package duvida;
- public class SenhaForte {
- public static void main(String[] args) {
- String str = "Ya5";
- if (validandoTamanho(str) && verificandoDigito(str) && verificaLetraMaiuscula(str)
- && verificaLetraMinuscula(str) && verificandoDigito(str))
- System.out.println("Senha segura!");
- else {
- System.out.printf("Senha não e forte!\n");
- if (str.length() < 6) {
- System.out.printf("Sua senha precisa ter mais %d caracteres", 6 - str.length());
- }
- }
- }
- public static boolean validandoTamanho(String s) {
- return (s.length() >= 6);
- }
- public static boolean verificandoDigito(String s) {
- char[] ch = s.toCharArray();
- for (int i = 0; i < ch.length; i++) {
- if (String.valueOf(ch[i]).matches("\\d+"))
- return true;
- }
- return false;
- }
- public static boolean verificaLetraMaiuscula(String s) {
- char[] ch = s.toCharArray();
- for (int i = 0; i < ch.length; i++) {
- if (String.valueOf(ch[i]).matches("\\p{Upper}+"))
- return true;
- }
- return false;
- }
- public static boolean verificaLetraMinuscula(String s) {
- char[] ch = s.toCharArray();
- for (int i = 0; i < ch.length; i++) {
- new String();
- if (String.valueOf(ch[i]).matches("\\p{Lower}+"))
- return true;
- }
- return false;
- }
- public static boolean verificaCaracterEspecial(String s) {
- char[] ch = s.toCharArray();
- for (int i = 0; i < ch.length; i++) {
- new String();
- if (String.valueOf(ch[i]).matches("\\p{Punct}+"))
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment