Answered step by step
Verified Expert Solution
Link Copied!

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 =

image text in transcribed
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
{
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);
}
}
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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

3. Distinguish between groups and effective teams.

Answered: 1 week ago