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
velikii [3]
3 years ago
11

Create a recursive method, a method that calls itself, that returns the number of vowels that appear in any string given. Keep i

n mind that we will need to have a base case that will stop the method when it finishes its work (going through the string and counting the vowels).
Computers and Technology
1 answer:
kvv77 [185]3 years ago
3 0
<h2>Answer:</h2>

//Define the method as noOfVowels

   //Let it receive the string to be checked as argument

   public static int noOfVowels(String string){

   

       //Check the length of the string

       

       //If it is less than 1, then it is an empty string

       //Hence return 0

       if(string.length() < 1){    

           return 0;

       }

       

       //Else,

       else{

           //get the character at the first position in the string

           //and convert it to a lower case

           char x = string.toLowerCase().charAt(0);

           //Check if the character is a vowel

           if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'){

               //if it is a vowel, add 1 to a recall of the method.

               //But this time, call the method with  

               //the string excluding the first character.

               //i.e the substring of the string starting at index 1 rather than 0

               return 1 + noOfVowels(string.substring(1));

           }

           

           else {

               //If it is not a vowel, just recall the method with

               //the string excluding the first character

               //i.e the substring of the string starting at index 1 rather than 0

               return noOfVowels(string.substring(1));

           }

       }

   }

   

<h2>Explanation:</h2><h2></h2>

The code has been written in Java and it contains comments explaining every part of the code. Please go through the comments carefully.

The actual lines of code have been written in bold face to distinguish them from comments.

The code is re-written without comments as follows;

   public static int noOfVowels(String string){

   

       if(string.length() < 1){    

           return 0;

       }

       

       else{

           char x = string.toLowerCase().charAt(0);

           if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'){

               return 1 + noOfVowels(string.substring(1));

           }

           

           else{

               return noOfVowels(string.substring(1));

           }

       }

   }

   

You might be interested in
Several families are planning a shared car trip on scenic drives in New Hampshire's White Mountains. To minimize the possibility
Rus_ich [418]

Answer:

Following are the response to the given question:  

Explanation:

Build a spring, sink, vertices, and vertices for each car for a household. Every unit in the stream is a human. Attach the source from each vertical of a family with such a capacity line equivalent to the family size; this sets the number of members in each household. Attach every car vertices to the sink with the edge of the car's passenger belt; this assures the correct number of people for every vehicle. Connecting every vertex in your household to any vertex in your vehicle with a capacity 1 border guarantees that one family member joins a single car. The link between both the acceptable allocation of people to vehicles as well as the maximum flow inside the graph seems clear to notice.

5 0
3 years ago
in triangle abc the value of cot a by 2 into cot B by 2 minus 1 whole divided by cot a by 2 into cot B by 2 is equal to​
netineya [11]

Answer: 2 + 2 is 4 minus 1 thats 3 quick mafs

Explanation:

8 0
3 years ago
Someone plz Help I am desperate.
sasho [114]

It would help if there is a programming language in the context of which you need this answered. For instance in Python you can create a program like this:

print(type("Hello"))

print(type(1337))

print(type(True))

print(type("3.14"))

It will return:

<class 'str'>

<class 'int'>

<class 'bool'>

<class 'str'>

8 0
3 years ago
Write a java program to read elements in an array from user and count total number of duplicate elements in array.
Anna11 [10]

Answer:

Explanation:

The following code is written in Java and is a function/method that takes in an int array as a parameter. The type of array can be changed. The function then creates a counter and loops through each element in the array comparing each one, whenever one element is found to be a duplicate it increases the counter by 1 and moves on to the next element in the array. Finally, it prints out the number of duplicates.

public static int countDuplicate (int[] arr) {

               int count = 0;

               for(int i = 0; i < arr.length; i++) {

                       for(int j = i + 1; j < arr.length; j++) {

                               if(arr[i] == arr[j])

                                       count++;

                       }

               }

               return count;

       }

8 0
3 years ago
An engineer plans to acquire data from a disk. The disk is connected to the forensics workstation and is ready for the engineer.
aksik [14]

The correct steps that indicate a correct order of acquisition as they relate to integrity and non-repudiation are:

  • A hash of the disk is made
  • A bit-by-bit copy is made
  • A second hash is made
  • A copy is made of the reference image

<h3>Is non-repudiation an aspect of integrity?</h3>

In general, nonrepudiation is known to be a term that puts together or combines authentication and integrity.

Note that Nonrepudiation is said to be a key or one of the pillars that pertains to information assurance.

The integrity in cyber security is known to be the act of keeping safe against any form of an improper information modification or destruction.

Hence, The correct steps that indicate a correct order of acquisition as they relate to integrity and non-repudiation are:

  • A hash of the disk is made
  • A bit-by-bit copy is made
  • A second hash is made
  • A copy is made of the reference image

Learn more about acquisition from

brainly.com/question/11412887

#SPJ1

8 0
2 years ago
Other questions:
  • You wish to enter your exam scores in a spreadsheet. Which function will help you find how each subject’s score relates to the o
    8·1 answer
  • Write two statements to read in values for birthMonth followed by birthYear, separated by a space. Write a statement to print th
    12·1 answer
  • Select the correct answer.
    9·1 answer
  • A user prefers an external monitor, mouse, and keyboard for a laptop. The user does not want to use the built-in screen; however
    5·1 answer
  • When dealing with a person who is behaving violently you should argue with them. A. False B. True
    5·1 answer
  • CottonPlus, a sportswear company, is releasing a new casual sportswear line. The company approaches a basketball star to endorse
    14·1 answer
  • Gabriel's sister called him about a message that suddenly appeared on her screen that says her software license has expired and
    11·1 answer
  • In order to enhance the training experience and emphasize the core security goals and mission, it is recommended that the execut
    5·1 answer
  • Create a set of functions that compute the mean, median, and mode of a set of
    8·2 answers
  • KELLY Connect
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!