I NEED THE ANSWER IN JAVA PLEASE NOT ANY OTHER LANGUAGE I NE

I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE.

I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE.

I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE.

I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE.

Vowel Count

Write a program that reads a string from the user then determines and prints the number of vowels (uppercase and lowercase) in the string.

You will need:

An assignment statement to store the string value entered.

Two string methods – one to read each character, and another to return the length of the string. (Hint: Figure 3.1 in your text will be helpful.)

A for loop to cycle through the string. You MUST use a for loop.The loop should start at the first position (or index) in the string and end when the string is done (i.e. when you have reached the full length of the string.

Hint: what value is designated for the first position of a string?

Use the string method that returns the length as part of your condition.

In this loop you will need one switch statement. This switch statement will use both the ‘fall through method’ (for upper and lower case versions of the same vowel, as well as break statements (to separate one vowel from another.)

Use the string method that returns the character as the expression in your switch statement.

Output statements for the number of vowels.

Sample output:

Enter a string of characters:
Hello! I am Finn from the land of Ooo.

Number of each vowel in the string:
a: 2
e: 2
i: 2
o: 6
u: 0

Code Shell

//*********************************************************
// VowelCount.java       
//
// This program counts the number of vowels in a string
//*********************************************************

import java.util.Scanner;

public class VowelCount
{
   public static void main(String[] args)
   {
     /*declare variables to store the number
     of each type of vowel*/

     Scanner scan = new Scanner(System.in);

     //Get the string from the user (prompt and input)


     /* format for this part:
     
         for (initializaton; condition; update)
         {
             switch (exp)
             {
                 cases and statements go here
             
             
             }
             
         }
         
         Remember:
         1) condition should use method for getting string
           length
         2) exp (in switch) should use method for returning
           a character
     
     */

     //Output results
   }
}

I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE.

I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE.

I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE.

Solution

Hi, Please find my code.

Please let me know in case of any issue.

import java.util.Scanner;

public class VowelCount

{

   public static void main(String[] args)

   {

       /*declare variables to store the number

   of each type of vowel*/

       int a=0, e=0, i=0, o=0, u=0;

       Scanner scan = new Scanner(System.in);

       //Get the string from the user (prompt and input)

       System.out.println(\"Enter a string of characters: \");

       String inputStr = scan.nextLine();

   for (int index=0; index<inputStr.length(); index++)

   {

   switch (inputStr.charAt(index))

   {

   case \'a\':

   case \'A\':

       a++; break;

     

   case \'e\':

   case \'E\':

       e++; break;

     

   case \'i\':

   case \'I\':

       i++; break;

     

   case \'o\':

   case \'O\':

       o++; break;

     

   case \'u\':

   case \'U\':

       u++; break;

   }

   }

   System.out.println(\"Number of each vowel in the string:\");

   System.out.println(\"a: \"+a);

   System.out.println(\"e: \"+e);

   System.out.println(\"i: \"+i);

   System.out.println(\"o: \"+o);

   System.out.println(\"u: \"+u);

   }

}

/*

Sample Output:

Enter a string of characters:

Hello! I am Finn from the land of Ooo.

Number of each vowel in the string:

a: 2

e: 2

i: 2

o: 6

u: 0

*/

I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE. I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE. I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OT
I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE. I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE. I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OT
I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE. I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE. I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OT
I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE. I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OTHER LANGUAGE. I NEED THE ANSWER IN JAVA PLEASE. NOT ANY OT

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site