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
This has nothing to do with anything school related, but I'm new to car audio and I was wondering, what happens or what would ha
DerKrebs [107]
It most likely can but It may damage your system. So you should seek out professional help from a car dealership and do more research.

Hope this helps.<span />
7 0
2 years ago
The recelver in a communication exchange can always ellminate all barriers to the communication.
gogolik [260]
It’s false because I know it
3 0
3 years ago
What is one of the key components of a typical formula?
hoa [83]

A formula key components are:

  • Functions
  • References
  • Operators
  • Constants.

<h3>What is a formula?</h3>

This is known to be a kind of mathematical relationship or rule that is said to be expressed in form of symbols.

Therefore, A formula key components are:

  • Functions
  • References
  • Operators
  • Constants.

Learn more about formula from

brainly.com/question/2005046

#SPJ11

4 0
1 year ago
Um its a weird question, but i want to ask anyways. Please dont report! I really need an answer!
den301095 [7]

okay here is what i got.

try restarting your wifi router and if that doesn't work then restart the console.

other than that i got nothing

hope this helps.

7 0
3 years ago
Read 2 more answers
Jane is a full-time student on a somewhat limited budget, taking online classes, and she loves to play the latest video games. S
Minchanka [31]

Answer:

a. A workstation with a 3.9 GHz quad-core processor, 16 gigabytes of RAM, and a 24" monitor.

Explanation:

From the description, Jane needs to be able to multitask and run various programs at the same time in order to be efficient. Also since she wants to play the latest video games she will need high end hardware. Therefore, from the available options the best one would be a workstation with a 3.9 GHz quad-core processor, 16 gigabytes of RAM, and a 24" monitor. This has a very fast cpu with 4 cores to process various threads at the same time. It also has 16GB of memory to be able to multitask without problems and a 24" monitor. From the available options this is the best choice.

6 0
3 years ago
Other questions:
  • An indicator is a comprehensive analysis of critical information
    8·1 answer
  • The official record of a high school student's performance is called:
    6·1 answer
  • Live.com is Microsoft's free web-based email provider.<br> A. True<br> B. False
    6·1 answer
  • True or False?
    7·1 answer
  • What is better for the sd card use as portable storage or use as internal storage?
    15·1 answer
  • Devices which are used to receive data from central processing unit are classified as
    11·1 answer
  • What are other ways you could use the shake or compass code blocks in physical computing projects?
    14·1 answer
  • Sustainable development is a goal towards which all human societies need to be moving. elaborate the statement in about 120 word
    9·1 answer
  • The User Datagram Protocol (UDP) is called the connectionless protocol because: It does not attempt to fix bad packets but resen
    8·1 answer
  • Which actions represent parody?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!