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
The two mathematical models of language description are generation and recognition. Describe how each can define the syntax of a
JulijaS [17]

Answer:

The correct answer to the following question will be "Semantic and Syntax error".

Explanation:

<u>Syntax error: </u>

Corresponds to such a mistake in a pattern sentence structure that is composed in either a specific language of that same coding. Because computer programs have to maintain strict syntax to execute appropriately, any elements of code that would not adhere to the programming or scripting language syntax can result inside a syntax error.

<u>Semantic error: </u>

That would be a logical error. This is because of erroneous logical statements. Write inaccurate logic or code of a program, which results incorrectly whenever the directives are implemented.

So, it's the right answer.

3 0
3 years ago
What type of device can be used to block unwanted traffic initiated from the internet and can also restrict internet access from
statuscvo [17]
It is the firewall exactly.
4 0
3 years ago
Which key must be pressed in addition to clicking on a hyperlink for it to be followed?
iogann1982 [59]

The key you need to press together with the click to be able to redirect to a hyperlink is the Control key.

In an electronic environment, a hyperlink is usually a word or phrase, highlighted in blue and underlined, or even an image, found in a web text and containing the command to "transfer" the user to another relevant web page, from the source node to the destination node.

By selecting this word or phrase the user has the ability to further research a topic from a variety of perspectives to compare information from different sources and actors.

Learn more in brainly.com/question/7620368

7 0
2 years ago
Mention five importance of taskbar​
sveticcg [70]

Answer:

The taskbar is an element of an operating system located at the bottom of the screen. It allows you to locate and launch programs through Start and the Start menu, or view any program that's currently open.

6 0
2 years ago
In a school 50% of the students are younger than 10, 1/20 are 10 years old and 1/10 are older than 10 but younger than 12, the r
Zielflug [23.3K]

Answer: 10 students

Explanation:

Students younger than 10 = 50%

Students that are 10years old = 1/20 = 1/20 × 100 = 5%

Students that are older than 10 but younger than 12 = 1/10= 1/10 × 100 = 10%

Students that are 12 years or older

= 100% - (50% + 5% + 10%)

= 100% - 65%

= 35%

This means that 35% of the students are 12 years or older and we've been given the number as 70.

Let's say the total number of students is x. Therefore,

35% of x = 70

0.35 × x = 70

0.35x = 70

x = 70/0.35

x = 200

The total number of students is 200.

Therefore, the number of students that are 10years will be:

= 1/20 × 200

= 10 students

Therefore, 10 students are 10 years.

3 0
2 years ago
Other questions:
  • 12. In 2009, __________ of all pedestrian fatalities were caused by impaired drivers
    9·2 answers
  • In your own words, describe what Internet Protocols are. Why is it important to have agreed upon protocols?
    6·1 answer
  • The _ are the devices that allow a computer system to communicate and interact with the outside world as well as store informati
    11·1 answer
  • Which CSS attribute would change an element's font color to blue? font-color: blue; background: blue; color: blue; background-co
    10·2 answers
  • Consider the classes below: public class TestA { public static void main(String[] args) { int x = 2; int y = 20 int counter = 0;
    8·1 answer
  • Write the proghrams for the following:
    13·1 answer
  • Chapter 15 Problem 6 PREVENTIVE CONTROLS Listed here are five scenarios. For each scenario, discuss the possible damages that ca
    11·1 answer
  • Project manager Erica is discussing with her team to prepare a document to describe the deliverables and goals of a software pro
    13·1 answer
  • The profile picture that you plan to use to market your professional brand on social media networks should feature you only.
    12·1 answer
  • your manager asked you to set up a secure network connection at a remote site to move over some back ups. what protocol what do
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!