Computer Science, asked by alishakhan, 1 year ago

write a program using string functions for class X

Attachments:

Answers

Answered by Archita1234
1
import java.scanner.*;
class string
{
public static void main (String args[])
{
Scanner SC =new Scanner(System.in);
String s, s1="";
int l, i;
char c;
System.out.println("Enter a word") ;
s=SC.next()
l=s.length();
for (i=0;i<l;i++)
{
c =s.charAt(i);
if(Character.isUpperCase(c))
{
s1=s1+Character.toLowerCase(c);
}
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
{
if(c! ='z')
{
s1=s1+(char)(c+1);
}
else
{
s1=s1+"a";
}
}
}
System.out.println("New word : "+s1);
}
}

alishakhan: can you do it with scanner class
Archita1234: ok I have edited the answer but I would advise you to check it on computer because I am not that confident with scanner... hope it helps! :)
alishakhan: ok
alishakhan: its correct
alishakhan: it should be next line
Archita1234: nope you have been told to input a word not sentence next line is used for sentence.. in this case if you input a word both will be same but logically it should be next function
alishakhan: okk
Answered by Justin01
2

Explanation:

gud night

sweet dreams...

Similar questions