+ 3
What's wrong with this code?
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner ask = new Scanner(System.in); String password = ask.nextLine(); String[] numbers={"1","2","3","4","5","6","7","8","9","0"}; String[] symbols={":","&","!","_","?","+","=","#","
quot;,"@","*","%","<"}; String result = ""; for (int x = 0; x < 10; x++){ if (password.contains(numbers[x])){ result += numbers[x]; } } String result_2 = ""; for (int y = 0; y < 14; y++){ if (password.contains(symbols[y])){ result_2 += symbols[y]; } } if (password.length() >=7 && result.length() >=2 && result_2.length() >= 2){ System.out.println("Strong"); } else { System.out.println("Weak"); } } } The check for symbols and numbers doesn't store duplicates don't know why?4 Réponses
+ 3
Bahha🐧 oops that code is a wrong version sorry, I actually addressed that place
+ 3
Jayakrishna🇮🇳 thanks, I'll try that.
+ 1
the for loop for symbols is not going to work.
int y = 0 ; y > 14
y is not greater than 14
and the length of symbols is 12
index star from 0
so should be y < 13
+ 1
Tedd Bug🐝 you should compare in reverse like symbols, numbers contains password individual charecters.....