Create a program that analyzes the vowels in a character string. Define a null-t
ID: 3797575 • Letter: C
Question
Explanation / Answer
VowelAnalysis.java :
package org.chegg;
import java.util.Scanner;
public class VowelAnalysis {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter string:");
String str = sc.next();
int count = 0 ;
StringBuffer sb = new StringBuffer();
onlyforARM200(str);
for(int i=0;i<str.length();i++){
boolean flag = vowelFinding(str.charAt(i));
if(flag){
sb.append(Character.toUpperCase(str.charAt(i)));
count++;
}
else
sb.append(str.charAt(i));
}
String result = sb.toString();
onlyforARM200(result);
System.out.println("Number of vowels in a string:"+count);
}
public static void onlyforARM200(String s){
System.out.println(s);
}
public static boolean vowelFinding(char ch){
String vowel = "aeiou";
boolean f = false;
for(int j=0;j<vowel.length();j++)
if(ch==vowel.charAt(j)){
f = true;
break;
}
return f;
}
}
sampleInput & output:
Enter string:
lakeshmaeonionrao// given string
lakeshmaeonionrao// original string
lAkEshmAEOnIOnrAO//result string
Number of vowels in a string:9
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.