Question: Can someone please help me debug this? I cannot get my results past my last integer or #3 to print out correctly. I will rate

Can someone please help me debug this? I cannot get my results past my "last integer" or #3 to print out correctly. I will rate for good/correct solutions and decent explanation of what I am not doing correctly. Thank you in advance!

import java.util.*;

public class Assignment06 {

public static void main(String[] args) {

int[] myArray = {1, 22, 333, 400, 5005, 9}; System.out.print("Your array: "); printArray(myArray, ", "); System.out.println(""); System.out.print("Your array: "); printArray(myArray, " - "); System.out.println(""); System.out.print("The first integer in the array is: "); System.out.print(getFirst(myArray)); System.out.println(""); System.out.print("The last integer in the array is: "); System.out.print(getLast(myArray)); System.out.println(""); System.out.print("The array with all but the first integer is: "); System.out.print(getAllButFirst(myArray)); System.out.println(""); System.out.print("The position of the minimum integer is: "); System.out.print(getIndexOfMin(myArray)); System.out.println(""); System.out.print("The position of the maximum integer is: "); System.out.print(getIndexOfMax(myArray)); System.out.println(""); System.out.print("The array after swapping positions 1 and 4 is: "); printArray(swapByIndex(myArray, 1, 4), null); System.out.println(""); System.out.print("The array after removing index3 is: "); printArray(removeAtIndex(myArray, 3), null); System.out.println(""); System.out.print("The array after adding 777 to index position 2 is: "); printArray(insertAtIndex(myArray, 2, 777), null); System.out.println(""); System.out.print("The array is in sorted order: "); System.out.print(isSorted(myArray)); } //#1 public static void printArray(int[] a, String s) { for (int i = 0; i < a.length; i++) { if(i!= a.length-1) { System.out.println(a[i]+s); } else { System.out.print(a[i]); } } } //#2 public static int getFirst(int[] a) { //this method will return int value at index position 0 return a[0]; } //#3 public static int getLast (int[] a) { //this calls array a to use its index integers and then returns the last position of array a return a[a.length-1]; } //#4 public static int[] getAllButFirst(int[] a) { int[] arr4 = new int[a.length-1]; for (int i = 1; imax6) { max6=a[i]; //set the index of the max to x x=i; } } return x; } //#7 public static int[] swapByIndex(int[] a, int x, int y) { int temp=a[x]; a[x]=a[y]; a[y]=temp; return a; } //#8 public static int[] removeAtIndex(int[] a, int x) { //set up the array //set arr8 to use specified array a int[] arr8 = new int[a.length-1]; //initiate the index int index=0; for (int i = 0;ix) { arr9[i]=a[i-1]; } } //return the array with the new value added return arr9; } //10 public static boolean isSorted(int[] a) { for (int i = 0; ia[i+1]) { return false; } } return true; }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!