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
During the course of execution of a program, the processor will increment the contents of the instruction register (program coun
Oksana_A [137]
Bdbdbdhdhdhdhdjdbsbbrvrvrrvrvrvfvfvvfvfvfvfvfhdhdhdhdhdhdhhdududududududuebebbedvdvd I known why ahh it happened
8 0
2 years ago
Henry wants to use handheld computers to take customers' orders in her restaurant. He is thinking of using custom written, open
DochEvi [55]

Answer: See explanation

Explanation:

Custom written software refers to the software that's developed for some particular organization or users. It's crates in order to meet the unique requirements of a business.

Since Henry is thinking of using custom written, open source software, then a custom written software will be used. Examples of custom written software will be automated invoicing, bug tracking software, E-commerce software solutions etc.

7 0
2 years ago
In general, a unit test may need drivers and stubs, but not both.<br><br> TRUE OR FALSE
Ymorist [56]

Answer:

True

Explanation:

If a module or code is not ready then the unit test can use the Stubs to simulate a called upon function to test the process. On the other hand if the main unit is not ready the test can use Drivers to simulate the calling of said function to test the rest of the modules.

Therefore, a unit test will use either Drivers or Stubs at a given moment for testing but not both simultaneously.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

5 0
3 years ago
Consider Ron’s budget. How much money does Ron have left over each month?
vladimir1956 [14]
What is Ron’s budget?
4 0
3 years ago
Read 2 more answers
Taking a break is necessary while using your computer or any other gadget. What are ways of having a break? Give five examples
mina [271]

Answer:

1) is to stretch or do some workouts

2) is to read

3) is to play outside for an hour

4) is to do gardening

5) is rest

3 0
2 years ago
Read 2 more answers
Other questions:
  • ​a(n) ____ is a communications device that connects a communications channel such as the internet to a device such as a computer
    11·1 answer
  • Choose a developing country and give 3 reasons why it is a developing country ​
    15·1 answer
  • Microsoft <br> Excel Module 6
    11·1 answer
  • Which of the following specific components are incorporated on HDInsight clusters?
    13·1 answer
  • What is a type of machine-to-human communication?
    14·1 answer
  • If you want Nud3s add me on sc Kermit4lyfe1
    11·2 answers
  • What is an border in html
    8·1 answer
  • Which is not one of the four criteria for proving the correctness of a logical pretest loop construct of the form: while B do S
    14·1 answer
  • Jackie is planning a surprise birthday party for her best friend and is researching a location to have the party. Jackie found a
    6·1 answer
  • Question 7 Consider the following code:
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!