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]
4 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]4 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
What command enables you to initialize quotas on a file system?
jeka57 [31]
 Quotas can be enabled by mounting a partition with the usrquota (and optionally the grpquota) mount option(s).Normally this is done by editing /etc/fstab and adding usrquota to the mount options part of the entry for some filesystem.Then that <span>filesystem must be remounted ("mount -o remount filesystem").</span>
4 0
3 years ago
Complete the steps to evaluate the following
kirill115 [55]

Answer:

log base 3a= -0.631.log a/3 base 3

Now, -log m= log 1/m

hence,

log base 3a= 0.631.log 3/a base 3

log base 3a/log 3/a base 3 =0.631

log base 3 ( a.3/a) =.631 since, log m/logn =log n(m)

log base 3 3=0.631

Hence, answer is log base 3 3=0.631

Explanation:

Please check the answer section.

3 0
3 years ago
Read 2 more answers
what is the term used when a virus takes control of features on your computer and transports files or information automatically?
Akimi4 [234]

Answer: a "worm"

Explanation:

3 0
3 years ago
What are the three main desktop operating systems used today
Norma-Jean [14]

Answer:The three most common operating systems for personal computers are Microsoft Windows, macOS, and Linux.

Explanation:

3 0
3 years ago
The processing that’s done by the DBMS is typically referred to as:______.
Vilka [71]

Answer:

Option b is the correct answer for the above question.

Explanation:

The DBMS is used to manage the information or data which is stored to use in the future. Any project has two sides one is the front end and the other is back-end. The front-end refers to the graphics which are visible to the user of the project but the data is not stored on the side of the project it is stored on any database software which can be called for the request of any event of the project. The database is stored on the backed of the project so to bring the data from the database, the process is known as back-end processing.

The above question wants to ask about the process of DBMS which is said to the back-end process because the DBMS process the data and to process the data is known as the back-end process. So Option b is  the correct while the other is not because--

  • Option 'a' states about front-end-processing which processes the design of the websites.
  • Option c states about the file server which is said to the DBMS.
  • Option d states about the management system which is not in the project.
5 0
4 years ago
Other questions:
  • Objectivity is only a small part of assessing a Web site. <br> a. True<br> b. False
    10·1 answer
  • How come the scroll bar on the PA emojis only appears sometimes? how do I make it appear?
    12·1 answer
  • Write a program to enter a number and test if it is greater than 45.6.if the number entered is greater than 45.6 the program nee
    13·1 answer
  • What happens when you get 3 warnings on this site?
    9·2 answers
  • What features are offered by most of the email programs with for receiving and sending messages?
    10·1 answer
  • Which of the following statements about federal student loans is true?
    7·1 answer
  • Write code to check that HairEyeColor is an array. e) Write code to determine: (i) the total number of respondents in the survey
    6·1 answer
  • Windows displays a(n)
    11·1 answer
  • It is a type of web page that allows you to share your ideas experiences and beliefs
    9·1 answer
  • What is the function of ROM?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!