Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.util.Scanner; * This program counts the number of vowels in a sentence where the string * * For example, if the sentence string is
import java.util.Scanner; * This program counts the number of vowels in a sentence where the string * * For example, if the sentence string is "hello how are you" the number of vowels is: * * +7 (e, o, o, a, e, o, U) * */ public class CountVowels { public static void main(String[] args) { String sentence = "The quick brown fox jumps over the lazy dog"; J //-----------Start below here. To do: approximate lines of code = 1 // Create an integer variable called vowelcount and initialize it to a //---- -End here. Please do not remove this comment. Reminder: no changes outside the todo regions. //----- ---Start below here. To do: approximate lines of code = 9 // Write a for loop that counts from 0 to the length-1 of the string variable sentence (see above) // Inside the loop use the charAt() method of the String class and check if the current character of the sentence is a vowel. // If it is, increment vowelCount by 1 // A vowel is defined as one of the following characters 'a' 'e' i 'A 'E! 'I' 'Y' //---- --End here. Please do not remove this comment. Reminder: no changes outside the todo regions. System.out.println("Vowel Count = + vowelCount); System.out.println("Expected: "); System.out.println("Vowel Count = + 12)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started