# Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What...

###### Question:

Please complete the following programming with clear explanations. Thanks!

Homework 1 – Programming with Java:

Classes (methods and attributes) •

Objects

Arrays of Primitive Values

Arrays of Objects

Recursion

for and if Statements

Selection Sort

Use the following Guidelines:
Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.)

Use upper case for constants. • Use title case (first letter is upper case) for classes.

Use lower case with uppercase word separators for all other identifiers (variables, methods, objects).

Use tabs or spaces to indent code within blocks (code surrounded by braces).

This includes classes, methods, and code associated with if, switch and loop statements. Be consistent with the number of spaces or tabs that you use to indent.

A description of what this program is doing.

3. Part 1. Primitive Types, Searching, Recursion

a) Create a class Homework (in a file Homework.java)

b) Create a static method initializeArray that receives as a parameter an array of characters. Use a for loop and an if statement to put ‘b’ in the odd positions of the array and ‘a’ in the even positions.

c) Create a static method printArray that receives as a parameter an array of
characters. Use a for statements to print all the elements in the array.

d) Create a static method selectionSort that receives as a parameter an array of characters and order its elements in ascending order. Implement Selection Sort algorithm. It should be Selection Sort, not Bubble Sort, not Quick Sort, etc. If you do not remember selection sort, this link could be useful: https://www.geeksforgeeks.org/java-program-forselection-sort/

e) Create a static recursive method named factorial that calculate and returns the factorial of a number. The method receives a number (integer number) as parameter.

f) Copy the following main method in your class, again the main method,

public class Homework {

public static void main (String [] arg) {

char [] a = {'a', 'b', 'c', 'd', 'x', 'y', '1', '2', '3', '4'};

char [] b = {'p', 'q', '9', '8' ,'7', '6'};

int [] c = {6, 0, 1};

// Testing initializeArray

printArray(a);

initializeArray(a);

printArray(a);

// Testing selectionSort

printArray(b);

selectionSort (b);

printArray(b);

// Testing factorial

System.out.println ( factorial (5) );

System.out.println ( factorial (c[0] );

System.out.println ( factorial (c[2] );

}

}

#### Similar Solved Questions

##### Can you do problem (c)? Suppose that blood chloride concentration (mmol/L) has a normal distribution with...
can you do problem (c)? Suppose that blood chloride concentration (mmol/L) has a normal distribution with mean 105 and standard deviation 5 What is the probability that chloride concentration equals 106? Is less than 106? Is at most 106? (Round your answers to four decimal places.) equals 106 less t...
##### What is the zero to peak amplitude in (N/C) of an electric field if there is...
What is the zero to peak amplitude in (N/C) of an electric field if there is an electromagnetic wave in free space with a time average intensity of 60 watts/meter squared?...
##### Please show cash flows, NPV, IRR, and payback period Sneaker 2013 The business case team had...
Please show cash flows, NPV, IRR, and payback period Sneaker 2013 The business case team had compiled the following baseline information surrounding the Sneaker 2013 project: 1. The life of the Sneaker 2013 project was expected to be six years. Assume the analysis took place at the end of 2012. 2. ...
##### Consider the following sample data drawn independently from normally distributed populations with equal population variances. Use...
Consider the following sample data drawn independently from normally distributed populations with equal population variances. Use Table 2. Sample 1 12.7 11.7 7.8 11.6 10.8 10.4 94 10.7 Sample 2 8.7 10.8 13.5 11.8 11.5 95 10.8 11.8 Click here for the Excel Data File a. Construct the relevant hypothes...
##### Mark up your resume so that the different sections of the resume are styled using the...
Mark up your resume so that the different sections of the resume are styled using the box attributes we discussed in class on 4/4/2018. For example, create different box styles, colors, thicknesses, margins, padding, alignments, etc. Make sure each section is style differently so that you have exper...
##### How fast would something have rotate in order to create earth like gravity from centrifugal force?
How fast would something have rotate in order to create earth like gravity from centrifugal force?...
##### Using the following 3 securities calculate: 1. Expected return 2. Variance 3. Standard deviation 4. Correlation...
Using the following 3 securities calculate: 1. Expected return 2. Variance 3. Standard deviation 4. Correlation between all possible pairs 5. Covariance between all possible pairs Probability Stock A .10 .10 .30 .20 .30 5% 5% 12% 6% 18% Stock B 35% 31% 30% 25% 17% Stock C 2% 6% 10% 15% 20%...
##### Problem 14.60 Review1 Constants 1 Periodic Table Part As we've seen, astronauts measure their mass by...
Problem 14.60 Review1 Constants 1 Periodic Table Part As we've seen, astronauts measure their mass by measuring the period of oscilation when siting in a chair connected to a spring The Body Mass Measurement Device on Skylab, a 1970s space station, had a spring constant of 606 N/m. The empty cha...
##### (3) Suppose that a stock is trading at 50 and you want to buy it when...
(3) Suppose that a stock is trading at 50 and you want to buy it when the price becomes 55, what order type should you submit? And at what price level (or range)?...
##### Unions in developed nations often oppose imports from low-wage countries and advocate trade barriers to protect...
Unions in developed nations often oppose imports from low-wage countries and advocate trade barriers to protect jobs from what they often characterize as “unfair” import competition. Is such competition “unfair”? Do you think that this argument is in the best interests of (a)...
##### 2a², where [Fixed Point Iterations, 15 pts). Let g(2) = -22 + 3x + a a...
2a², where [Fixed Point Iterations, 15 pts). Let g(2) = -22 + 3x + a a is a parameter. (a) Show that a is a fixed point of g(x). (b) For what values of a does the iteration scheme On+1 = g(n) converge linearly to the fixed point a (provided zo is chosen sufficiently close to a)? (c) Is there a ...
Pureform, Inc., uses the FIFO method in its process costing system. It manufactures a product that passes through two departments. Data for a recent month for the first department follow: Materials $84,400 Labor$ 42,200 Overhead \$ 55,900 Work in process inventory, beginning Units started in proces...