Created
March 9, 2021 20:34
-
-
Save gitaficionado/93cc673927b2d202bbbeee0067b4d6df to your computer and use it in GitHub Desktop.
Beginning code for StringStatsArray class
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
import java.util.Scanner; | |
public class StringStatsArray{ | |
private final String[] arr; | |
public StringStatsArray(String[] a){ | |
arr = a; | |
} | |
/* Iterate through and cancatenate all values surrounded by quotes except last and follow each with a comma. | |
Create string with a "{" the beginning and end it with a "}". | |
*/ | |
/* | |
Create a sum variable as 0. Then, itereate through and add each String length. Be sure to return sum divided | |
by array length (cast to double if sum as an int). | |
*/ | |
/* | |
Iterate through each value in array in turn. If value is equal to target return the index. | |
Finally, at the end of iteration return -1 as item is not found. | |
*/ | |
/* | |
Create booleans for alphabetical/reverse alphabetical sequence as true. Then, iterate through all except first value. You | |
should also be able to compare the value to previous one useing compareTo method. | |
*/ | |
/* Works in the same way as sortStatus in the NumStatsArray class, but uses | |
* the compareTo method to determine if one String appears alphabetically | |
* after the other. | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment