Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java program that implements two recursive methods in addition to the main method. 1. The first method when you pass it an integer

Write a java program that implements two recursive methods in addition to the main method.

1. The first method when you pass it an integer (n for example) is supposed to print lines of asterisks in the following format: * ** *** **** **** *** ** * For example if you pass the function the number 1, it will print * * if you pass the number 2 * ** ** * if you pass the number 3 * ** *** *** ** * So basically given n, it will print n lines starting with one asterisk on line 1 followed by two asterisks on line 2, all the way to n asterisks on line n. Then after line n it is supposed to print the mirror image of the first n lines that you printed. This method must be recursive.

2. The second method when you pass it an array of integers, it splits the array into odd an even sections. It will put the odd numbers at the beginning of the array and the even numbers at the end of the array. The algorithm should work even if the array is all odd or all even. Example: If you input [10,4,5,2,8,7,9,11,3,6] The output would be: [5,7,9,11,3,10,4,2,8,0,6] 3.

Testing the methods. You need to implement a main method in your class that is supposed to do the following: 1. Ask the user to read an integer (n) 2. Pass the integer to the first method to print the asterisks in the format mentioned above. 3. Ask the user to read another integer (can also be n) which represents the size of the array to be read in. After you read the integer n, read that many integers and store them in an array, and call the second method and print the resulting array which is split into odd and even section.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions