import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class BonusExercises { /* complete the method below, so it will validate an email address 1. Must have exactly one @ (no more, no less) 2. Split into local-part and domain (before @ and after @) 3. Local-part rules: - Can't be empty - Can't start or end with dot - Can't have two dots in a row 4. Domain rules: - Can't be empty - Can't start or end with hyphen - Can't have underscores - Each segment (between dots) must follow same hyphen rules */ public boolean validateEmail(String email) { String regex = ""; // todo int indexAt = 0; int Atnum = 0 ; int datnum = 0 ; int dat1 = 0; int dat2 = 0 ; int emsize = email.length() ; for (int i = 0 ; i < email.length(); i ++) { if (email.charAt(i) == '@') { indexAt = i ; Atnum ++ ; } if (email.charAt(i) == ' ') { return false ; } } if (Atnum != 1) { return false ; } if(indexAt == 0) { return false ; } if (indexAt == 1 && email.charAt(0) == ' ') { return false ; } if (email.charAt(0) == '.' || email.charAt(Atnum-1) == '.') { return false ; } for (int i = 0 ; i 1) { return false ; } if(indexAt== (emsize-1)) { return false ; } if (indexAt == (emsize-2) && email.charAt(emsize-1) == ' ' ) { return false ; } if (email.charAt(indexAt+1) == '-' || email.charAt(emsize-1) == '-') { return false ; } for (int i = indexAt ; i =8) { len = true ; } i = j-1 ; if (len && check_lower && check_number && check_special && check_upper) { FinalNumber ++ ; } } } return FinalNumber; } /* you should return a list of *words* which are palindromic by word we mean at least 3 letters with no whitespace in it vv note: your implementation should be case-insensitive, e.g. Aba -> is palindrome */ public List findPalindromes(String string) { List list = new ArrayList<>(); // todo int size = string.length() ; for (int i = 0 ; i < size ; i ++) { if(string.charAt(i)==' ') continue; String pal = "" ; String pal2 = "" ; String pal3 = "" ; String spe = "!?.*," ; int j = i ; while (j < size && string.charAt(j) != ' ' ) { char y = string.charAt(j) ; if (Character.isLetter(y)) { pal3 = pal3 + y; pal = Character.toLowerCase(y) + pal; pal2 = pal2 + Character.toLowerCase(y); } j++ ; } if (pal2.equals(pal) && pal3.length()>=3) { list.add(pal3) ; } i = j - 1 ; } return list; } public static void main(String[] args) { // you can test your code here } }