So here it is Pschemo my entire code, thanks a lot, there is no problem no errors and everything is just fine. But just one thing to asks at the first time when I enter all the elements of the array and I type stop, it shifts one line as I wrote System.out.println(), and then I have to press enter once again, then it show my designed Thank You message and the rest of Output. Why this happens?
Any Clue?
import java.util.ArrayList;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
class End_Start_Vowels
{
public static void main() throws InterruptedException
{
String fs="yes";
while(fs.equalsIgnoreCase("yes"))
{
Scanner in=new Scanner(System.in);
ArrayList <String> a= new ArrayList<String>();
String b; int c=0;
char d;
int total=0;
int v=0;
int o=0;
int w=0;
int e=0;
int l=0;
System.out.println("start tping below, type stop or end to stop.");
do
{
b=in.nextLine();
a.add(b);
c++;
}
while(!b.equalsIgnoreCase("stop")&&!b.equalsIgnoreCase("end"));
if(c<2)
a.clear();
int z=a.size();
if(c>=2)
a.remove(z-1);
System.out.println();
if(c<2)
System.out.println("No word are typed. Please type continue to restart it");
String s1=in.nextLine();
if(c<2)
{ if(s1.equalsIgnoreCase("continue")){
System.out.println("start tping below, type stop or end to stop.");
do
{
b=in.nextLine();
a.add(b);
c++;
}
while(!b.equalsIgnoreCase("stop")&&!b.equalsIgnoreCase("end"));
if(c<2)
a.clear();
z=a.size();
if(c>=2)
a.remove(z-1);
System.out.println();
for(int j=0;j<a.size();j++)
{
String s=a.get(j);
for(int i=0;i<s.length();i++)
{
d=s.charAt(i);
if(d=='a'||d=='A')
{v++; total++;}
if(d=='E'||d=='e')
{ o++; total++;}
if(d=='i'||d=='I')
{w++; total++;}
if(d=='O'||d=='o')
{ e++; total++;}
if(d=='u'||d=='U')
{ l++; total++;}
}
}
if(c>=2)
{
System.out.println("Thanks for using!");
TimeUnit.SECONDS.sleep(1);
System.out.println("Showing you the frequencies of each vowels.");
TimeUnit.SECONDS.sleep(1);
System.out.println();
System.out.println("Frequency of vowel a is ="+v);
System.out.println("Frequency of vowel e is ="+o);
System.out.println("Frequency of vowel i is ="+w);
System.out.println("Frequency of vowel o is ="+e);
System.out.println("Frequency of vowel u is ="+l);
System.out.println();
System.out.println("Total number of vowels present is ="+total);
}
}
}
else
{
for(int j=0;j<a.size();j++)
{
String s=a.get(j);
for(int i=0;i<s.length();i++)
{
d=s.charAt(i);
if(d=='a'||d=='A')
{v++; total++;}
if(d=='E'||d=='e')
{ o++; total++;}
if(d=='i'||d=='I')
{w++; total++;}
if(d=='O'||d=='o')
{ e++; total++;}
if(d=='u'||d=='U')
{ l++; total++;}
}
}
if(c>=2)
{
System.out.println("Thanks for using!");
TimeUnit.SECONDS.sleep(1);
System.out.println("Showing you the frequencies of each vowels.");
TimeUnit.SECONDS.sleep(1);
System.out.println();
System.out.println("Frequency of vowel a is ="+v);
System.out.println("Frequency of vowel e is ="+o);
System.out.println("Frequency of vowel i is ="+w);
System.out.println("Frequency of vowel o is ="+e);
System.out.println("Frequency of vowel u is ="+l);
System.out.println();
System.out.println("Total number of vowels present is ="+total);
}
}
System.out.println();
TimeUnit.SECONDS.sleep(1);
System.out.println("Do you want to use it again, type yes to continue.");
fs=in.nextLine();
System.out.println();
}
}
}