WAP in Java to perform the following Operation in String(Icse String Program)
Input:vital information resources under seize
Output:virus
import java.util.*;
class jit
{
public static void main(String args[])
{
int i,l;
char c;
String s,w="";
Scanner sc=new Scanner(System.in);
System.out.println("Enter the String");
s=sc.nextLine();
for(i=0;i<s.length();i++)
{
c=s.charAt(i);
if(c==' ')
{
w=w+(s.charAt(i+1));
}
}
System.out.print(w);
}
}
Input:vital information resources under seize
Output:virus
import java.util.*;
class jit
{
public static void main(String args[])
{
int i,l;
char c;
String s,w="";
Scanner sc=new Scanner(System.in);
System.out.println("Enter the String");
s=sc.nextLine();
for(i=0;i<s.length();i++)
{
c=s.charAt(i);
if(c==' ')
{
w=w+(s.charAt(i+1));
}
}
System.out.print(w);
}
}
Comments
Post a Comment