Created
March 9, 2021 20:13
-
-
Save gitaficionado/1ed86f78f491a14d2f4fe28a7d08a81d to your computer and use it in GitHub Desktop.
Beginning structure of NumStatsArray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NumStatsArray{ | |
//Create a private array as a double as final | |
________________________________________ | |
public NumStatsArray(double[] a){ | |
arr = a; | |
} | |
//Iterate through and cancatenate all values except last and follow each with a comma. Creat string with a "{" the beginning and end it with a "}". | |
public String toString() | |
//Create a method that returns average fo all values as a double. Be sure to crate a sum variable as a double. | |
/* Create min and max variables set to first value in array. Then, iterate all values and update max every time new | |
largest value found. Finally, update min every time new smallest value found and return min - max. | |
*/ | |
// Create booleans for ascending/descending sequence as true. | |
/* Iterates through all except the first value in the array, and checks if | |
* current value is smaller than the previous (meaning arr is not decreasing | |
* or is greater than the previous (meaning arr is not increasing). | |
*/ | |
// check increasing first, so if all are same, 1 is returned | |
if(increasing) | |
return 1; | |
if(decreasing) | |
return -1; | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment