Menu

Please Complete Following Programming Clear Explanations Thanks Homework 1 Programming Jav Q43893959

Please complete the following programming with clearexplanations. Thanks!

Homework 1 – Programming with Java:

What This Assignment Is About?

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 isupper case) for classes.

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

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

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

Use white space to make your program more readable.

For each file (class) in your assignment, provide a heading (incomments) which includes:
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 aparameter an array of characters. Use a for loop and an ifstatement to put ‘b’ in the odd positions of the array and ‘a’ inthe even positions.

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

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

e) Create a static recursive method named factorial that calculateand 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 mainmethod,

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] );

}

}

Expert Answer


Answer to Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What Th…

OR