Snowball String

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

1 comment:

any problem in any program comment:-

Second largest number in java using ternary operator

 //Largest second number using ternary operator public class Main { public static void main(String[] args) { int a=5,b=6,c=7; int ...