This program can count number of vowels in a sentence but only ifthey are lower
ID: 3614394 • Letter: T
Question
This program can count number of vowels in a sentence but only ifthey are lower case.I don't know how l can make it to also countuppercase vowels.import javax.swing.*;
public class ExamPractise
{
public static void main (String [] geek)
{
String sentence =JOptionPane.showInputDialog("Enter a any sentence");
int countVowels=0;
int countSentences=0;
int countWords=0;
int countCharacters;
for (int i = 0; i <sentence.length(); i++)
{
char c =sentence.charAt(i);
if (c=='a' ||c=='e' || c=='i' || c=='o' || c=='u')
{
countVowels++;
}
}
System.out.println("There are" + " " + countVowels + " " +"vowels");
}
}
Explanation / Answer
for (int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.