I'm trying to write a program that asks the user to enter a single letter untill they enter a (.) They hit enter after each letter, but the loop wont continue. It asks them to enter a letter, then it sks for another letter (because it's not a peroid) but then it just stops. The loop doesnt continue. Even if they enter a peroid the second time, it wont accept it.
Thanks
Code:
public class J12Q5
// counting letters
{
public static void main(String[]args) throws IOException
{
InputStreamReader inStream = new InputStreamReader(System.in);
BufferedReader stdin = new BufferedReader(inStream);
int counter = 1;
int Numb;
int something = 0;
System.out.println("Please enter a letter.");
String letters = stdin.readLine();
while (something != 1) // does a loop while the letters dots not say peroid.
{
if (letters == ".")
{
System.out.println("You entered " + counter + "Letters");
something = 1;
break;
}
else
{
System.out.println("please enter another letter.");
letters = stdin.readLine();
counter += 1;
break;
}
}
}
}
Thanks
Comment