I am working on his project and I am having trouble understanding the actual questions. Here they are...
ArrayOperations:
This class has no field variables. Dont add any!!
Add a static method that performs a sequential search for a given number and returns the subscript.
Add a static method that performs a sort of the array.
Add a static method that performs a binary search of the sorted array and returns the subscript.
Develop the above methods for both int and double data types. Do not develop methods for float and long data types.
Overload each method with a different array data type.
NOTE: Inside of the above methods do not code the size of the array. The array size must be determined by the demo program.
Use the correct data types!!
ArrayOperationsDemo:
Initialize the arrays in code.
Use 5, 2, 4, 3, 1, 6 as the integer array.
Use 8.0, 1.0, 7.0, 2.0, 6.0, 3.0, 5.0, 4.0 as the double array.
Display your initial array.
Your demo class should use each method in the ArrayOperations class at least once.
For each search method, search for a value that is in the array and a value that is not in the array.
Display the result of each method you use.
This is the basic problem in the book that includes the above.
Write a class name ArrayOperations with the following static methods.
getTotal, accepts 1-Dimentional array as argument and return total of values in array. Overload Int,Double.
getAverage, accepts 1-Dimentional array as argument and returns average of values in array. Overload Int,Double.
getHighest, accepts 1-Dimentional array as argument and returns Highest values in array. Overload Int, Double.
getLowest, accepts 1-Dimentional array as argument and returns Lowest values in array. Overload Int, Double.
^ What should these look like compared to mine.
Demonstrate the class in complete program with test data stored in arras of various data types.
This is the class I am working on so far.
ArrayOperations:
This class has no field variables. Dont add any!!
Add a static method that performs a sequential search for a given number and returns the subscript.
Add a static method that performs a sort of the array.
Add a static method that performs a binary search of the sorted array and returns the subscript.
Develop the above methods for both int and double data types. Do not develop methods for float and long data types.
Overload each method with a different array data type.
NOTE: Inside of the above methods do not code the size of the array. The array size must be determined by the demo program.
Use the correct data types!!
ArrayOperationsDemo:
Initialize the arrays in code.
Use 5, 2, 4, 3, 1, 6 as the integer array.
Use 8.0, 1.0, 7.0, 2.0, 6.0, 3.0, 5.0, 4.0 as the double array.
Display your initial array.
Your demo class should use each method in the ArrayOperations class at least once.
For each search method, search for a value that is in the array and a value that is not in the array.
Display the result of each method you use.
This is the basic problem in the book that includes the above.
Write a class name ArrayOperations with the following static methods.
getTotal, accepts 1-Dimentional array as argument and return total of values in array. Overload Int,Double.
getAverage, accepts 1-Dimentional array as argument and returns average of values in array. Overload Int,Double.
getHighest, accepts 1-Dimentional array as argument and returns Highest values in array. Overload Int, Double.
getLowest, accepts 1-Dimentional array as argument and returns Lowest values in array. Overload Int, Double.
^ What should these look like compared to mine.
Demonstrate the class in complete program with test data stored in arras of various data types.
This is the class I am working on so far.
public class ArrayOperations {
//Sequential Search
public static int sequentialSearch(int [] array, int value) {
int index,
start;
boolean found;
index = 0;
start = -1;
found = false;
while (!found && index < array.length) {
if (array[index] == value) {
found = true;
start = index;
}
index++;
}
return start;
}
}
//Sequential Double
public static double sequentialSearch(double [] array, double value) {
double index,
start;
boolean found;
index = 0;
start = -1;
found = false;
while (!found && index < array.length) {
if (array[index] == value) {
found = true;
start = index;
}
index++;
}
return start;
}
}
//Sort Selection
public static void selectionSort(int[] array) {
int startScan, index, minIndex, minValue;
for(startScan, = 0; startScan < (aray.length-1); startScann++) {
minIndex = startScan;
minValue = array[startScan];
for(index = startScan + 1; index < array.length; index++) {
if(arra[index] <minValue) {
minValue = array[index];
minIndex = index;
}
}
array[minIndex] = array[startScan];
array[startScan] = minValue;
}
}
//Sort Double
public static void selectionSort(double[] array) {
double startScan, index, minIndex, minValue;
for(startScan, = 0; startScan < (array.length-1); startScan++) {
minIndex = startScan;
minValue = array[startScan];
for(index = startScan + 1; index < array.length; index++) {
if(array[index] <minValue) {
minValue = array[index];
minIndex = index;
}
}
array[minIndex] = array[startScan];
array[startScan] = minValue;
}
}
//Binary Search
public static int binarySearch(int[] array, int value) {
int first,
last,
middle,
position;
boolean found;
first = 0;
last = array.length -1;
position = -1;
found = false;
while(!found && first <= last) {
middle = (first + last) / 2;
if(arra[middle] == value) {
found = true;
position = middle;
}
else if(array[middle] > value)
last = middle - 1;
else{
first = middle + 1;
}
return position;
}
//Binary Double
public static double binarySearch(double[] array, double value) {
double first,
last,
middle,
position;
boolean found;
first = 0;
last = array.length -1;
position = -1;
found = false;
while(!found && first <= last) {
middle = (first + last) / 2;
if(arra[middle] == value) {
found = true;
position = middle;
}
else if(array[middle] > value)
last = middle - 1;
else{
first = middle + 1;
}
return position;
}
public static int getTotal() {
}
public static double getTotal() {
}
public static int getAverage() {
}
public static double getAverage() {
}
public static int getHighest() {
}
public static double getHighest() {
}
public static int getLowest() {
}
public static double getLowest() {
}