1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
iVinArrow [24]
3 years ago
5

Write a program named CountVowelsModularized that passes a string to a method that returns the number of vowels in the string.

Computers and Technology
1 answer:
KengaRu [80]3 years ago
7 0

Answer:

<em>import java.util.Scanner;</em>

<em>public class CountVowelsModularized {</em>

<em>    public static void main(String[] args) {</em>

<em>        Scanner in = new Scanner (System.in);</em>

//Prompt user to enter a string, receive it and assign to a variable<em>        </em>

<em>System.out.println("Enter a string Value");</em>

<em>        String word =in.nextLine();</em>

//Calling the method numVowels and passing the string

<em>        System.out.println("The Number of vowels are " +numVowels(word.toLowerCase()));</em>

<em>    }</em>

<em>}</em>

The method definition and complete program is given in the explanation section<em> </em>

Explanation:

<em>import java.util.Scanner;</em>

<em>public class CountVowelsModularized {</em>

<em>    public static void main(String[] args) {</em>

<em>        Scanner in = new Scanner (System.in);</em>

<em>        System.out.println("Enter a string Value");</em>

<em>        String word =in.nextLine();</em>

<em />

<em>        System.out.println("The Number of vowels are " +numVowels(word.toLowerCase()));</em>

<em>    }</em>

<em>    public static int numVowels(String string) {</em>

<em>        int counter = 0;</em>

<em>        for (int i = 0; i < string.length(); i++) {</em>

<em>            if (string.charAt(i) == 'a' || string.charAt(i) == 'e' || string.charAt(i) == 'i'</em>

<em>                    || string.charAt(i) == 'o' || string.charAt(i) == 'u') {</em>

<em>                counter++;</em>

<em>            }</em>

<em>        }</em>

<em>        return counter;</em>

<em>    }</em>

<em>}</em>

You might be interested in
Write a program FindDuplicate.java that reads n integer arguments from the command line into an integer array of length n, where
kozerog [31]

Answer:

  1. public class FindDuplicate{
  2.    public static void main(String[] args) {
  3.        Scanner input = new Scanner(System.in);
  4.        int n = 5;
  5.        int arr[] = new int[n];
  6.        for(int i=0; i < arr.length; i++){
  7.            int inputNum = input.nextInt();
  8.            if(inputNum >=1 && inputNum <=n) {
  9.                arr[i] = inputNum;
  10.            }
  11.        }
  12.        for(int j =0; j < arr.length; j++){
  13.            for(int k = 0; k < arr.length; k++){
  14.                if(j == k){
  15.                    continue;
  16.                }else{
  17.                    if(arr[j] == arr[k]){
  18.                        System.out.println("True");
  19.                        return;
  20.                    }
  21.                }
  22.            }
  23.        }
  24.        System.out.println("False");
  25.    }
  26. }

Explanation:

Firstly, create a Scanner object to get user input (Line 4).

Next, create an array with n-size (Line 7) and then create a for-loop to get user repeatedly enter an integer and assign the input value to the array (Line 9 - 14).

Next, create a double layer for-loop to check the each element in the array against the other elements to see if there is any duplication detected and display "True" (Line 21 - 22). If duplication is found the program will display True and terminate the whole program using return (Line 23). The condition set in Line 18 is to ensure the comparison is not between the same element.

If all the elements in the array are unique the if block (Line 21 - 23) won't run and it will proceed to Line 28 to display message "False".

7 0
3 years ago
OH NO THE HEAVY IS DEAD
Anarel [89]

Answer:

what does that mean?

are you okay?

Did something happen?

4 0
3 years ago
Read 2 more answers
Which of the following are breach prevention best practices?Access only the minimum amount of PHI/personally identifiable inform
Rudiy27

Answer:

All of this above.

Explanation:

All the mentioned practices can be use to prevent breaches.

6 0
3 years ago
Which binary number is equivalent to the decimal number 104?
ra1l [238]

B. 01101000

For future reference you can look up decimal to binary calculators online; or binary to decimal.

6 0
3 years ago
Question 3 / 5
Andrej [43]

Answer:

False

Explanation:

3 0
3 years ago
Other questions:
  • QUESTION 56 Use the Windows ________ to check on a nonresponsive program. Backup utility Error-checking System Restore Task Mana
    6·1 answer
  • A _____ is one in which the size of the web page and the size of its elements are set regardless of the screen resolution..
    8·1 answer
  • What is targets net worth in 2020 (i will see if you put in 2019)
    11·1 answer
  • How do I type over Images (photo posted ​
    12·2 answers
  • What finger should be on the Y key?
    12·2 answers
  • Examples of email use that could be considered unethical include _____.
    14·2 answers
  • An example of computer hardware is ? A. keyboard B. app C. web browser D. operating system
    13·2 answers
  • Write a program to check the password( qbasic)​
    8·1 answer
  • In binary, the second digit from the right is multiplied by the first power of two, and the _____ digit from the right is multip
    10·2 answers
  • Need help:(!!!! I’ll mark brainliest if correct
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!