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
Often technical personnel who are not familiar with security techniques think that restricting access to ports on a router or fi
zavuch27 [327]

Answer:

This is not a good solution

Explanation:

Your web browser uses port 80 outgoing to make web requests, so if you’re blocking incoming port 80, all you’re blocking is users of the organization from connecting to the internet. You have indeed close a vulnerable port to access from hackers, but this also can reduce the productivity of the organization.

3 0
3 years ago
PowerPoint displays many that are varied and appealing and give you an excellent start at designing a presentation. However, you
Jet001 [13]

Answer:

The answer is themes.

Power point displays many <u>themes</u>

Explanation:

A power point theme is a combination of effects,fonts and colors that can be applied to the presentation.It makes the presentation more attractive and beautiful if used properly and smartly.Power point has built in themes that gives excellent start to your presentation.

5 0
3 years ago
Consider the following code segment.
mafiozo [28]

Answer:

for (int h = k; h >= 0; h--)

Explanation:

From the list of given options, option C answers the question.

In the outer loop

Initially, k = 0

In the inner loop,

h = k = 0

The value of h will be printed once because h>=0  means 0>=0 and this implies once

To the outer loop

k = 1

The inner loop will always assume value of k;

So,

h = 1

This will be printed twice because of the condition h>=0  means 1>=0.

Since 1 and 0 are >=0; 1 will be printed twice

To the outer loop

k = 2

The inner loop

h = 2

This will be printed thrice because of the condition h>=0  means 2>=0.

Since 2, 1 and 0 are >=0; 2 will be printed thrice

To the outer loop

k = 3

The inner loop

h = 3

This will be printed four times because of the condition h>=0  means 3>=0.

Since 3, 2, 1 and 0 are >=0; 3 will be printed four times

7 0
3 years ago
A _____ miniature battery operated transmitter that can be propelled through a non-metallic pipe or purpose of locating
Anna11 [10]
I think it is the model ET-2. Not quite sure.
7 0
2 years ago
The it components of an erp system architecture include the hardware, software and the ________
natta225 [31]

The components of an ERP system architecture is made up of the hardware, software and the Data.

<h3>What is an ERP system?</h3>

Enterprise resource planning (ERP) is known to be a kind of  software that firms often use to handle or manage day-to-day business works such as accounting and others.

Note that The components of an ERP system architecture is made up of the hardware, software and the Data.

Learn more about  ERP system from

brainly.com/question/14635097

#SPJ12

6 0
2 years ago
Other questions:
  • Dinah is using an I.D.E to write, modify, and save code. Which tool should she use?
    8·2 answers
  • Kuta software infinite pre- algebra multiplying polynomial and a monomial find product answer key
    14·1 answer
  • Technically
    12·1 answer
  • How to identify mistakes in a html code??​
    14·1 answer
  • 1. Which one of the following is true about screening interviews?
    7·1 answer
  • Write a definition in your own words for intranet. Please don't copy and paste.
    7·2 answers
  • Web designers use programming languages to write websites. A True <br> B False​
    15·2 answers
  • What is meant by reflection?​
    9·2 answers
  • Describe who was Alan Turing in 100 words.<br> First to answer will get brainliest.
    7·1 answer
  • Which internet explorer security feature restricts the browsing session information that can be tracked by external third-party
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!