Hi guys>.<
I'm trying to make a program that suppose to output like this:
Enter a String: 1231asd
No. of Digit: 4
End the Program? y
*the red part is the input from the user.
but the problem is, the no. of digits only display 0 and not the total digit
in the string. can anyone help me with this please :C. I've been searching through
the internet but can't find anything related to my problem.
This is a code that I came up with no reference other than
txt1.indexOf(txt2)>=0 and .equalsIgnoreCase()
so if anyone could point the things that shouldn't be there please do so.
:) thank you in advance to anyone that will take their time to help me
String text;
int idx, ctrDigit=0;
String ans;
String digit = "0123456789";
do{
System.out.print("Enter a String: ");
text = in.nextLine();
text.equalsIgnoreCase(text);
for(idx=0; idx < text.length(); idx++)
if(digit.indexOf(text)>=0)
ctrDigit++;
System.out.println();
System.out.println("No. of Digits: " + ctrDigit);
System.out.print("End the program? ");
ans = in.nextLine();
}while(ans.indexOf("n")>=0 || ans.equalsIgnoreCase("NO"));
System.out.println();
}}