Concept explainers
(Occurrences of a specified character in an array) Write a recursive method that finds the number of occurrences of a specified character in an array. You need to define the following two methods. The second one is a recursive helper method.
public static int count(char[] chars, char ch)
public static int count(char[] chars, char ch, int high)
Write a test
Want to see the full answer?
Check out a sample textbook solutionChapter 18 Solutions
Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++: Early Objects (9th Edition)
Electric Circuits. (11th Edition)
SURVEY OF OPERATING SYSTEMS
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Modern Database Management
Starting Out with C++ from Control Structures to Objects (9th Edition)
- 1.Answer the following questions: 1(a) Write a method to compute and return the value of maxEven and minOdd where maxEven is the largest even element of an int array and minOdd is the smallest odd element of the int array. The method is passed the int array and an int value that denotes the number of elements in the array. You may assume that the int array has at least 1 element in it. 1(b) Write a method to compute and return the value of countEven and countOdd where countEven is the number even elements in an int array and countOdd is the number of odd elements in the int array. The method is passed the int array and an int value that denotes the number of elements in the array. You may assume that the int array has at least 1 element in it.arrow_forwardWrite a program to accomplish the following tasks:- a) Write a method to print the ArrayList in the reverse order b) Write a method to sort the ArrayList, and display the data after sorting c) Write a method to print the largest and the smallest element in the ArrayList d) In the main method ask user to enter 10 integers, store them in the ArrayList, pass the ArrayList to above methods, and then display the result after each call.arrow_forwardWrite pseudocode that will a.) initialize an array with 5 values and declare a second empty array of the same size. b.) copy the contents of the first array into the second array. (Hint: use a loop.) Java 1 public class FinalGrade2 {3 public static void main(String args[])4 {5 //variable declarations and initialization6 String studentName = "Nicholas Simoneaux";7 final double QUIZ_PERCENTAGE = 0.5;8 final double TEST_PERCENTAGE = 0.5;910 double quizOne = 98.5;11 double quizTwo = 77.0;12 double quizAverage;13 double testOne = 85.0;14 double testTwo = 67.0;15 double testAverage;16 double extraCredit = 10.0;17 double finalGrade;1819 //calculations20 quizAverage = quizOne + quizTwo / 2;21 testAverage = testOne + testTwo / 2;2223 finalGrade = (quizAverage * QUIZ_PERCENTAGE) + (testAverage * TEST_PERCENTAGE) + extraCredit; 24 25 //output26 System.out.println("Student…arrow_forward
- TASK 1 Write a Java method that returns the index of the smallest element in an array of integers. If the number of such elements is greater than 1, return the smallest index. Use the following header: public static int indexofLargestlestelement(double[] array) Write a test program that prompts the user to enter ten numbers, invokes this method to return the index of the smallest element, and displays the index.arrow_forwardWrite method body of following methods: DeleteNum(int position) // This method will delete element from array at position entered by the user arrange the data after that position to left. (Using While loop) DeleteNum(int from, int to) // This method will delete elements from array at range given by the user, as the user inputs two positions i.e start and end, the program should than delete all numbers in that range. (Use C++ to code)arrow_forwardJava Programming [ Using Array] - 1arrow_forward
- Computer Science using javaarrow_forwardUsing Javaarrow_forwardPart III - Create Your Own Art Art.java In this part you will create a program Art.java that produces a recursive drawing of your own design. This part is meant to be fun, but here are some guidelines in case you're not so artistic. Requirements Art.java must take one (1) integer command-line argument n that controls the depth of recursion. Your drawing must stay within the drawing window when n is between 1 and 7. (The autograder will not test values of n outside of this range.) You may not change the size of the drawing window (but you may change the scale). Do not add sound. Your drawing can be a geometric pattern, a random construction, or anything else that takes advantage of recursive functions. Your program must be organized into at least three separate functions, including main(). All functions except main() must be private. For full credit, Art.java must not be something that could be easily rewritten to use loops in place of recursion, and some aspects of the recursive…arrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage