+ 2
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"); } } } It doesn't count duplicate occurrence of the numbers and symbols don't know why.6 Answers
+ 2
So I know .contains() iterates through your whole string and returns true or false (1 or 0) and I see your code runs both of the if statements for symbols and numbers but doesnât add duplicate characters to result. You could try to make the result strings Integers for a count instead of adding characters to a string.
+ 2
also the 2nd for loop had ây > 14â where it should be ây < 13â
+ 2
Roderick Davis I'll try that.
Thanks
+ 1
https://code.sololearn.com/cohCpuq82J8U/?ref=app check mine out while I try to figure yours out đ€.
+ 1
and nice pic
+ 1
Roderick Davis sure