
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
![Write a static method named vowelsBeforeconsonants that accepts an array of characters as a parameter and rearranges
its elements so that all even vowels appear before the consonants. For example, if the following array is passed to your
method:
char[] numbers = {'r', 't', 'a', 'o', 'p', 'u'};
Then after the method has been called, one acceptable ordering of the elements would be:
{'a', 'o', 'u', 'r', 't', 'p'}
The exact order of the elements does not matter, so long as all vowels appear before all
For example, the following would also be an acceptable ordering:
consonants.
{'o', 'a', 'u', 't', 'p', 'r'}
Do not make any assumptions about the length of the array or the range of values it might contain. For example, the array
might contain no even vowels or no consonants. You may assume that the array is not null.
You may not use any temporary arrays to help you solve this problem. (But you may declare as
many simple variables as you like, such as chars.) You also may not use any other data structures such as the ArrayList
class from Chapter 10. DO NOT use Arrays.sort in your solution.
Hint: This is actually a sorting problem. In BubbleSort you tested pairs of elements and swapped them if the left element
is larger than the right element. In this problem, the swap happens when the left element is a vowel and the right element is
a consonant.](https://content.bartleby.com/qna-images/question/c4247586-c5ba-4193-bff0-fd146d066f71/701f8eb9-7d7f-4c5f-b574-d04aa4cea46e/1sc01w_thumbnail.png)
Transcribed Image Text:Write a static method named vowelsBeforeconsonants that accepts an array of characters as a parameter and rearranges
its elements so that all even vowels appear before the consonants. For example, if the following array is passed to your
method:
char[] numbers = {'r', 't', 'a', 'o', 'p', 'u'};
Then after the method has been called, one acceptable ordering of the elements would be:
{'a', 'o', 'u', 'r', 't', 'p'}
The exact order of the elements does not matter, so long as all vowels appear before all
For example, the following would also be an acceptable ordering:
consonants.
{'o', 'a', 'u', 't', 'p', 'r'}
Do not make any assumptions about the length of the array or the range of values it might contain. For example, the array
might contain no even vowels or no consonants. You may assume that the array is not null.
You may not use any temporary arrays to help you solve this problem. (But you may declare as
many simple variables as you like, such as chars.) You also may not use any other data structures such as the ArrayList
class from Chapter 10. DO NOT use Arrays.sort in your solution.
Hint: This is actually a sorting problem. In BubbleSort you tested pairs of elements and swapped them if the left element
is larger than the right element. In this problem, the swap happens when the left element is a vowel and the right element is
a consonant.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- In Java: Write a method that multiplies all elements in the array by 3 and returns it to the main method.arrow_forwardGiven the below 2 arrays: int arr1[] = { 9,8,7,6,5,4,3,2,1,0 }; int arr2[] = { 99, 89, 79, 69, 59 }; Write a program to replace 79 in arr2 with 4 from arr1. Print the final arr2 using Arrays.toString() method. Hint: Use System.arraycopy() methodNote: For all these programs, please submit the program’s .java file and screenshot of output.arrow_forwardMethod Details: public static java.lang.String getArrayString(int[] array, char separator) Return a string where each array entry (except the last one) is followed by the specified separator. An empty string will be return if the array has no elements. Parameters: array - separator - Returns: stringThrows:java.lang.IllegalArgumentException - When a null array parameter is providedarrow_forward
- A method named getUserStringsAndPopulate Array(). This method should keep prompting the user to enter as many strings as the user wants. The user should be able to stop entering strings by entering EXIT. This method should take the strings entered by the user and populate a one-dimensional array of strings with the user input. The string EXIT should NOT be added to the array because it is a special flag that will tell the method to stop prompting the user to enter more strings. This method should return the one-dimensional array of strings populated with user input and should not accept any arguments. 2.b) A method named searchArray() that would accept a one-dimensional array of strings and search the array for the string Winter. The search logic should NOT be case sensitive. If a match is found, this method should print the string in the array followed by a message like " --- Found a match!". Otherwise, the method should not print anything. This method should NOT return anything.…arrow_forward2. Write a method that takes a rectangular two-dimensional array of type int and returns a valu of type int. The method returns the number of rows with negative sum. A row has a negative s if the sum of all its elements is less than 0. public static int countNegativeSum(int[][] in) Taken array Result 1 -3 17 -5 -5 14 -5 -2 30 -19 -8 -8 1 1 3 -1 -4 78 8 -3 -5 -1 -1 3 -4arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education