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
A Uniform Resource Locator (URL) consists of three separate parts: network protocol, host, and web browser.
FrozenT [24]
That is false. are you doing it on a computer course.                                             <span />
3 0
3 years ago
Read 2 more answers
Put these operating systems in order according to the date they were released. (The first to be released would be
uysha [10]
1. ms-dos 1981
2. windows 2.0 1987
3. windows xp 2001
4. mac os 2001
5. windows 7 2009
8 0
3 years ago
The conflict between the user's goal for unfettered access to data and the security administrator's goal to protect that data is
rewona [7]

Answer: Access control

Explanation:Access control is the type of security facility that is provided to the systems in an organization. The functions carried out in maintaining the security of the system is done by authenticating , authorizing and identification of the users and related components . They are secured using the PINs , passwords, bio-metric scan etc.

The situation of the user wanting to have a unrestrained access towards data as well as maintaining the security is the done by access control.

8 0
2 years ago
Read 2 more answers
What is true about content based filtering
AleksAgata [21]

Answer: provide more info

Explanation:

8 0
2 years ago
⦁ Consider transferring an enormous file of L bytes from Host A to Host B. Assume an MSS of 536 bytes. ⦁ What is the maximum val
timurjin [86]

Answer:

a)  There are approximately  2^32 = 4,294,967,296 possible number of the sequence. This number of the sequence does not increase by one with every number of sequences but by byte number of data transferred. Therefore, the MSS size is insignificant. Thus, it can be inferred that the maximum L value is representable by 2^32 ≈ 4.19 Gbytes.

b)  ceil(2^32 / 536) = 8,012,999

The segment number is 66 bytes of header joined to every segment to get a cumulative sum of 528,857,934 bytes of header. Therefore, overall number of bytes sent will be 2^32 + 528,857,934 =  4.824 × 10^9 bytes.  Thus, we can conclude that the total time taken to send the file will be 249 seconds over a 155~Mbps link.

Explanation:

a)  There are approximately  2^32 = 4,294,967,296 possible number of the sequence. This number of the sequence does not increase by one with every number of sequences but by byte number of data transferred. Therefore, the MSS size is insignificant. Thus, it can be inferred that the maximum L value is representable by 2^32 ≈ 4.19 Gbytes.

b)  ceil(2^32 / 536) = 8,012,999

The segment number is 66 bytes of header joined to every segment to get a cumulative sum of 528,857,934 bytes of header. Therefore, overall number of bytes sent will be 2^32 + 528,857,934 =  4.824 × 10^9 bytes.  Thus, we can conclude that the total time taken to send the file will be 249 seconds over a 155~Mbps link.

8 0
2 years ago
Other questions:
  • The standard qwerty keyboard has 47 keys that can place characters on the screen. each of these keys can also display a second c
    13·2 answers
  • Which of the following best explains why some people invest their saving in the stock market and others put their saving in bank
    5·2 answers
  • Standards for all managers ethical responsibilities are covered in a company's
    7·2 answers
  • What is the post condition of an expression or variable
    11·1 answer
  • "what type of index has an index key value that points to a data row, which contains the key value? "
    9·1 answer
  • Witch of the following is a valid why a scientist might a scientific theory
    13·1 answer
  • Which of these is one of the primary concerns for protecting your family when online?
    9·2 answers
  • A company that manufactures machine parts orders a new system that makes products at ten times the speed of the earlier machine.
    15·1 answer
  • Please select the word from the list that best fits the definition Asking for review material for a test
    14·2 answers
  • can you guys plz answeer this i need help rrly bad and plz no viruses or links or answers that have nun to do with this
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!