So my program won't stop when the user inputs quit and also the variables keep adding up each time it's ran, when I only one them to count the characters in one run, then count the next input. So the program counts the specific characters in a string but I want it to count no matter what the first time and after the first time I want the user to have the option to say stop and end the program
public class Count {
public static void main (String[] args) {
String phrase; // a string of characters
int blankCount; // the number of blanks (spaces) in the phrase
int length; // the length of the phrase
char ch; // an individual character in the string
Scanner scanner = new Scanner(System.in);
System.out.println ();
System.out.println ("Character Counter");
System.out.println ();
System.out.print ("Enter a sentence or phrase: ");
blankCount = 0;
int aCount = 0;
int eCount = 0;
int sCount = 0;
int tCount = 0;
int timesRan = 0;
do {
phrase = scanner.nextLine();
length = phrase.length();
for(int i=0; i<length; i++){
switch(phrase.charAt(i)){
case ' ':
blankCount++;
break;
case 'a':
aCount++;
break;
case 'A':
aCount++;
break;
case 'e':
eCount++;
break;
case 'E':
eCount++;
break;
case 's':
sCount++;
break;
case 'S':
sCount++;
break;
case 't':
tCount++;
break;
case 'T':
tCount++;
break;
}
timesRan++;
}
System.out.println ("Number of space characters: " + blankCount);
System.out.println ("Number of a's: " + aCount);
System.out.println ("Number of e's: " + eCount);
System.out.println ("Number of s's: " + sCount);
System.out.println ("Number of t's: " + tCount);
System.out.print("Enter a phrase or enter quit, to quit: ");
} while(phrase != "quit" && timesRan >= 0);
}
}