I'm trying to identify if there is a number in the input provided using for loops. I've been trying to do it for a long time, and even searched on the second page of Google. I decided to ask for some help. Here's what I've tried so far:
for (c = 0 ; c < 6 ; c = c++)
{
c = input.charAt (0);
if (Character.isDigit (c))
{
System.out.println ("Input must only contain letters.");
return;
}
}
Basically I'm trying to scan through ever letter, and test them individually if they are a letter or a number, which is what I'm having trouble with, since only the first letter is scanned. I've tried typing "c++" in the loop as well. How would I do scan every letter?
Edit: Whoops, that was an mistake. I changed it to c = c + 1 but it didn't work, I changed it back to c++ but it ended up as c = c++.
You can't use
c
as the index and the value simultaneously. Try this: