I\'m working on a lab assignment and I\'m stuck the assignment is as follows: a)
ID: 3554291 • Letter: I
Question
I'm working on a lab assignment and I'm stuck the assignment is as follows:
a) Create a method for each of the operations given below. Each method should accept two 2D integer arrays (matrices) and return the result. The choice of operation should be taken from the user. The 2-D arrays can be declared and initialized in the main method itself (no need of user input).
1. Add 2. Subtract 3. Multiply
b) In this part, you will write a series of methods that implement sorting and searching algorithms. You will be provided with a file that contains 2,000 integers (no duplicates). Read the integers from the file and store them in an int array. Store the output for each method in a different text file.
Create the following methods
1. linear Search using loops which will return an integer number representing the index number of the element containing the search value or -1 if the value was NOT found. This method will receive an integer array and integer search value as parameters. The body of this method should be written using loops.
2. BubbleSort: This public static void method will implement the bubble sort algorithm using loops. It will receive an unsorted integer array as input, and will reorder the elements of the array.
3. Selection_Sort: This public Static void method will implement the selection sort algorithm using loops. It will receive an unsorted integer array as input, and will reorder the elements of the array.
4. Insertion Sort: This public Static void method will implement the insertion sort algorithm using loops. It will receive an unsorted integer array as input, and will reorder the elements of the array.
Here is what I have so far:
import java.util.Arrays;
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
public class Labassignment11 {
public static void main(String[] args) throws FileNotFoundException {
Scanner in = new Scanner(new File("//home//rmwade//Downloads//Int.txt"));
int [][] a = {{1,2},{1,5}};
int [][] b = {{2,5},{4,3}};
int [] c = new int[2000];
int i=0;
while(fileScanner.hasNext(i))
{
c[1] = fileScanner.nextInt();
i++;
}
try{
PrintWriter out = new PrintWriter("//home//rmwade//Downloads//IntNew.txt");
out.print(Arrays.toString(c));
out.close();
}catch (FileNotFoundException e){
e.printStackTrace();
}
} //End main
public static void add(int[][]x, int[][]y){
}// End Add
public static void subtract(int[][]x, int[][]y){
}//End Subtract
public static void multiplication(int[][]x, int[][]y){
}//End Multiplication
} //End Class
I can't attach the file so I can just copy & paste the integer's that need to be sorted if you think you need it to finish the code just ask in the comments. Thanks so much for any help!
Explanation / Answer
hey i am ready to do all your homeworks.
Can you be my client?