Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Generally I will run your Java program on jGrasp with Windows. Any Java program that you turn in will always be in a single file

Generally I will run your Java program on jGrasp with Windows.

 Any Java program that you turn in will always be in a single file named unfid.java where unfid is YOUR unf id. So , I would name my file n00009873.java . This implies that the name of the class containing main must be n00009873. So in this program you must change HighArray.java to unfid.java and ALSO rename the class HighArrayApp to unfid (always pay attention to capitalization). So , in general, my class containing main will be named n00009873 and the file containing all my classes will be named n00009873.java Program 2.1: To the HighArray class in the higharray.java program(Listing2.3) add a method called getMax() that returns the value of the highest key in the array, or -1 if the array is empty. Add some code in main() to excercise this method. You can assume all the keys are positive numbers. 1. Construct program 2.1 but you are going to write a getMin() method also. Make the last four lines of code: y=arr.getMax(); /*this should work with any data set not just the data he has. I will modify the data in your code to test it with several data sets. You should declare any variables like y and z that you need. The data might be all postive, all negative, or a mixture. But it will alwasy consists of ints, including possibly the int 0 */ System.out.println(y); z=arr.getMin(); System.out.println(z); All of the source code should be in a single file , named unfid.java So my file would be named n00009873.java I need you to name your file unfid.java 2. Compile the program using jGrasp to test it and then transfer that file to osprey.unf.edu using ssh. Generally, I will compile your file and then run it. You should do the same on Osprey or using jGrasp on Windows to make sure you have done everything properly. NEVER turnin ANY BINARY CODE IN THIS CLASS. NO LATE ASSIGNMENTS ACCEPTED..GET IT DONE EARLY! DO NOT USE shar for this assignment. Just turnin a single .java file

HighArray.java Template:

// highArray.java // demonstrates array class with high-level interface // to run this program: C>java HighArrayApp //////////////////////////////////////////////////////////////// class HighArray

{ private long[] a; // ref to array a private int nElems; // number of data items //-----------------------------------------------------------

public HighArray(int max) {

a = new long[max]; nElems = 0; }

// constructor

// create the array // no items yet

//----------------------------------------------------------- public boolean find(long searchKey)

{ int j; for(j=0; j

if(a[j] == searchKey)

// find specified value

// for each element, // found item?

break; if(j == nElems)

return false; else

public void insert(long value) {

a[nElems] = value; nElems++; }

// exit loop before end // gone to end? // yes, cant find it

// no, found it //-----------------------------------------------------------

return true; } // end find()

//----------------------------------------------------------- public boolean delete(long value)

{ int j; for(j=0; j

if( value == a[j] ) break;

if(j==nElems) return false;

else {

for(int k=j; k

nElems--; return true; }

// look for it

// cant find it // found it // move higher ones down // decrement size

} // end delete() //----------------------------------------------------------- public void display() // displays array contents

{ for(int j=0; j

System.out.print(a[j] + ); // display it System.out.println(); }

//-----------------------------------------------------------

} // end class HighArray //////////////////////////////////////////////////////////////// class HighArrayApp

{ public static void main(String[] args)

{ int maxSize = 100; HighArray arr; arr = new HighArray(maxSize);

arr.insert(77); arr.insert(99); arr.insert(44); arr.insert(55); arr.insert(22); arr.insert(88); arr.insert(11); arr.insert(00); arr.insert(66); arr.insert(33);

arr.display();

int searchKey = 35; if( arr.find(searchKey) )

// array size // reference to array // create the array

// insert 10 items

System.out.println(Found + searchKey); else

System.out.println(Cant find + searchKey);

arr.delete(00); arr.delete(55); arr.delete(99);

arr.display();

} // end main() } // end class HighArrayApp

// delete 3 items

// display items again

////////////////////////////////////////////////////////////////

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

Step: 3

blur-text-image

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 Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago