Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone help me create this program in java, I\'m having trouble finishing.

ID: 3551575 • Letter: C

Question

Can someone help me create this program in java, I'm having trouble finishing.





Programming Two: Implement one of the four algorithms in Section 3.1 We discussed four algorithms in Section 3.1. i e.. linear Search (Sequential Search) Algorithm, Binary Search Algorithm. Bubble Sort Algorithm and the Insertion Sort Algorithm In this assignment, you will write a java program to implement one of them and then demonstrate it Define a Java class You will define a Java class Inside the class, you will have two methods One is the 'public static void main', and the other is named as 'public void mylmplementation' The class will also include an integer array "data' for demonstrating the algorithm public class implementAlgorithm { int [] data = new int(10); public static void main(String [] args){ } public void mylmplementation(int [] data){ } In the "public static void mam' method, you will read 10 integers from the keyboard and call the "myImplementation' method to do either search or sorting After that, you will output the result to screen

Explanation / Answer

import java.util.ArrayList;

import java.util.Scanner;


public class implementAlgorithm{

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int i=0;

ArrayList<Integer> array = new ArrayList<Integer>();

for(i=0;i<10;i++){

System.out.print("Enter "+(i+1)+" number: ");

array.add(sc.nextInt());

}

System.out.print(" Enter numberto be searched: ");

i= myImplementation(array, sc.nextInt());

if (i==-1){

System.out.println("Not found");

}

else {

System.out.println("Found "+array.get(i)+" at Position "+(i+1));

}

sort(array);

}

public static int myImplementation(ArrayList<Integer> a, int b){

int i;

for (i=0;i<a.size();i++){

if(a.get(i)==b){

return i;

}

}

return -1;

}

public static void sort(ArrayList<Integer> a){

int i,j;

for(i=0; i<a.size();i++){

for(j=i+1;j<a.size();j++){

if(a.get(i)>a.get(j)){

a.set(i, a.get(i)+a.get(j));

a.set(j, a.get(i)-a.get(j));

a.set(i, a.get(i)-a.get(j));

}

}

}

System.out.print("Sorted Array :");

for(i=0; i<a.size();i++){

System.out.print(a.get(i)+" ");

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote