import java.io.*;
class Space
{
static String s;
int l=s.length();
int n=0;
int i;
public int lack(String x)
{
String c;
c=x;
for(i=0;i<l;i++)
{
char ch=c.charAt(i);
if(ch==' ')
{
n++;
}
}
return n;
}
public static void main(String args[]) throws IOException
{
DataInputString z=new DataInputString(System.in);
String x;
System.out.println(enter string");
x=z.readLine();
Space m= new Space();
int l=m.lack(s);
System.out.println("number of spaces are" +l);
}
}
class Space
{
static String s;
int l=s.length();
int n=0;
int i;
public int lack(String x)
{
String c;
c=x;
for(i=0;i<l;i++)
{
char ch=c.charAt(i);
if(ch==' ')
{
n++;
}
}
return n;
}
public static void main(String args[]) throws IOException
{
DataInputString z=new DataInputString(System.in);
String x;
System.out.println(enter string");
x=z.readLine();
Space m= new Space();
int l=m.lack(s);
System.out.println("number of spaces are" +l);
}
}
Comments