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

task 2 and 3 should be different classes and main use eclipce 2. Using the code

ID: 3746226 • Letter: T

Question

task 2 and 3 should be different classes and main use eclipce

2. Using the code HighArray, create a program that will read N numbers. Then, the program will do the following (10 Marks) a. b. c. d. e. Display the content of the array. Ask for a number to search and Output if the number is found or not. Ask for a number to delete and output if the number is deleted or not found. Ask for a number to insert and display the new content of the array. Display the highest key in the array. 3. Create a program that will implement the HighArray Class, declare three objects name Arr1 with an array size of 5, Arr2 with an array size of 5 and Arr3 with an array size of 10. Enter 5 numbers for each object Arr1 and Arr2. After filling the object Arr1 and Arr2, your next task is to fil-in the object Arr3 using the content of the Arr1 and Arr2, keep in mind that you need to fill-in Arr3 in alternate values coming from Arr1 and Arr2. Example Assuming the content of Arr1 (1,2,3,4,5) and Arr2 The result of Arr3 is (1,9,2,8,3,7,4,6,5,5) 9,8,7,6,5)

Explanation / Answer

import java.util.Scanner;

public class higharray

{

public static void main(String args[])

{

int arr[]=new int[10];

int n,i,search,x,flag=1,loc=0,insert,j,count=0,pos,max;

Scanner scan=new Scanner(System.in);

System.out.println("how many stements you want to store");

n=scan.nextInt();

System.out.println("enter="+n+" element to store in array");

for(i=0;i<n;i++)

{

arr[i]=scan.nextInt();

}

System.out.println("elemnets in array");

for(i=0; i<n; i++)

{

System.out.print(arr[i] + " ");

}

System.out.println("enter value to find");

search=scan.nextInt();

for(i=0;i<n;i++)

{

if(arr[i]==search)

{

System.out.println(search+"is present at location"+(i+1));

break;

}

}

if(i==n)

System.out.println(search + " isn't present in array.");

System.out.println("enter element you want to delete");

x=scan.nextInt();

for(i=0;i<n;i++)

{

if(arr[i]==x)

{

for(j=i;j<(n-1);j++)

{

arr[j]=arr[j+1];

}

count++;

break;

}

}

if(count==0)

{

System.out.print("Element Not Found..!!");

}

else

{

System.out.print("Element Deleted Successfully..!!");

System.out.print(" Now the New Array is : ");

for(i=0; i<(n-1); i++)

{

System.out.print(arr[i]+ " ");

}

System.out.println("enter element you want to insert");

insert=scan.nextInt();

  

System.out.print("At Which Position ? (Enter Index Number ) : ");

pos = scan.nextInt();

// now create a space at the required position

for(i=n; i>pos; i--)

{

arr[i] = arr[i-1];

}

arr[pos] = insert;

System.out.print("Element inserted Successfully..!! ");

System.out.print("Now the New Array is : ");

for(i=0; i<n; i++)

{

System.out.print(arr[i]+ " ");

}

max=arr[0];

for(i=0;i<n;i++)

{

if(max<arr[i])

{

max=arr[i];

}

}

System.out.println("maximum value"+max);

}

}

}

import java.util.Scanner;
public class higharray
{
public static void main( String args[])
{
Scanner scan=new Scanner(System.in);
int arr[] = new int[5];
int arr1[]=new int[5];
int n,i;
int arr2[]=new int[5*2];
System.out.println("lement of array");

for( i=0;i<5;i++)
{
arr[i]=scan.nextInt();
}
System.out.println("enter element of second array");
for( i=0;i<5;i++)
{
arr1[i]=scan.nextInt();
}
int j=0,k=0;
for(i=0;i<arr2.length;i++)
{
if(i%2==0)
arr2[i]=arr[j++];
else
arr2[i]=arr1[k++];
}
System.out.println("new array");
for(i=0;i<arr2.length;i++)
{
System.out.println(arr2[i]);
}
  
}
}