+ 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?

2nd Oct 2020, 4:58 PM
Divine Darkey
Divine Darkey - avatar
4 Respuestas
+ 3
Bahha🐧 oops that code is a wrong version sorry, I actually addressed that place
2nd Oct 2020, 6:08 PM
Divine Darkey
Divine Darkey - avatar
+ 3
Jayakrishna🇮🇳 thanks, I'll try that.
2nd Oct 2020, 9:06 PM
Divine Darkey
Divine Darkey - avatar
+ 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
2nd Oct 2020, 6:00 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
Tedd Bug🐝 you should compare in reverse like symbols, numbers contains password individual charecters.....
2nd Oct 2020, 8:01 PM
Jayakrishna 🇮🇳