Code is copied!
Define a class to accept a string and convert it into uppercase. Count and display the
number of vowels in it.
Input: robotics
Output: ROBOTICS
Number of vowels: 3
Solution:
,
import java.util.*;
class Vow
{
public static void main(String args[])
{
String str;int count=0;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the word:");
str = sc.next();
str=str.toUpperCase();
System.out.println("Output:"+str);
for(int i=0;i< str.length();i++)
{
char c=str.charAt(i);
if(c=='A'||c=='E'||c=='I'||c=='O'||c=='U')
{
count+=1;
}
}
System.out.println("Number of Vowels:"+count);
}
}