Computer Science, asked by meghma0055, 24 days ago

Write a program to input a word and print all the vowels present in the word
entered by the user.
Sample Input: computer
Sample output: o u e

Answers

Answered by kamalrajatjoshi94
9

Answer:

Program in Java:-

import java.util.*;

public class Main

{

public static void main(String args[])

{

Scanner in=new Scanner(System.in);

String st;

char ch;

System.out.println("Enter a String:");

st=in.nextLine();

System.out.println("The vowels in the String "+st+":");

for(int i=0;i<st.length();i++)

{

ch=st.charAt(i);

if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')

System.out.print(ch+" ");

}

}

}

Output is attached.

Attachments:
Answered by CopyThat
16

Answer:

JAVA ;

Explanation:

import java.util.*;

class Brainly

{

static void main()

{

Scanner sc=new Scanner(System.in);

String s,t="",w="";

int i,fa=0,fe=0,fi=0,fo=0,fu=0;

char x;

System.out.print("Enter a sentence:");

s=sc.nextLine();

s=s.trim();

s=s+" ";

for(i=0;i<s.length();i++)

{

x=s.charAt(i);

if(x!=' ')

{

w=w+x;

if(x=='a' || x=='A' ) fa=1;

if(x=='e' || x=='E') fe=1;

if(x=='i'|| x=='I') fi=1;

if(x=='o' || x=='O') fo=1;

if(x=='u' || x=='U') fu=1;

}

else

{

if(fa==1 && fe==1 && fi==1 && fo==1 && fu==1)

t=t+w+" ";

w="";

fa=fe=fi=fo=fu=0;

}

}

System.out.println("Word having all the five vowels:"+t);

}

}

Similar questions