Answered step by step
Verified Expert Solution
Question
1 Approved Answer
package p5_unsortedArrayAccess; import java.util.*; public class unsortedArrayAccess { public static double[] arr; private int arraySize; public unsortedArrayAccess(int scale) { arr = new double[scale]; arraySize =
package p5_unsortedArrayAccess;
import java.util.*;
public class unsortedArrayAccess
{
public static double[] arr;
private int arraySize;
public unsortedArrayAccess(int scale)
{
arr = new double[scale];
arraySize = 0;
}
public double get(int i)
{
return arr[i];
}
public int search(double Key)
{
int i = 0;
while ((arr[i] != Key) && (i
{
i = i + 1;
}
if (i
{
return i;
}
else
{
System.out.println("There is no such item!");
return -1;
}
}
public void append(double Item)
{
arr[arraySize] = Item;
arraySize = arraySize + 1;
}
public double remove()
{
if (arraySize == 0)
{
System.out.println("There is no item in the array!");
return -1;
}
double x = arr[arraySize - 1];
arraySize = arraySize - 1;
return x;
}
public void deletion(double Key)
{
int k = search(Key);
if (k != -1)
{
for (int i = k; i
4. Programming: .1 Download and study program P-1 Add a testing class that can test all the operations defined in the unsortedArray Access class. Make your testing menu-driven {
arr[i] = arr[i + 1];
}
arraySize = arraySize - 1;
};
}
public void display()
{
if (arraySize == 0)
{
System.out.println("Array is empty!");
}
else
{
for (int i = 0; i
{
System.out.println(arr[i]);
}
};
System.out.println("array size is " + arraySize);
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started