import java.io.*;
class snowball
{
public static void main()throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a string terminated by a full stop(.)");
String s=br.readLine();
int l = s.length();
int iofs = s.indexOf(' ');
String sw = s.substring(0,iofs);
int lsw = sw.length();
int i, p;
boolean flag = true;
p = iofs+1;
for(i=iofs+1; i < l;i++){
char ch = s.charAt(i);
if(ch == ' ' || ch == '.'){
String w = s.substring(p,i);
if(lsw > w.length()){
flag = false;
break;
}
p = i+1;
}
}
if(flag)
System.out.println("Snowball string");
else
System.out.println("Not a snowball string");
}//eom
}//eoc
class snowball
{
public static void main()throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a string terminated by a full stop(.)");
String s=br.readLine();
int l = s.length();
int iofs = s.indexOf(' ');
String sw = s.substring(0,iofs);
int lsw = sw.length();
int i, p;
boolean flag = true;
p = iofs+1;
for(i=iofs+1; i < l;i++){
char ch = s.charAt(i);
if(ch == ' ' || ch == '.'){
String w = s.substring(p,i);
if(lsw > w.length()){
flag = false;
break;
}
p = i+1;
}
}
if(flag)
System.out.println("Snowball string");
else
System.out.println("Not a snowball string");
}//eom
}//eoc
I loved your post.Much thanks again. Fantastic.
ReplyDeleteaws online training