Not sure what to put to get largest integer in this array?

int[] freqCount(int[] roll){
  int[] freqs= new int [NUM_SIDES];
  for(int i=0; i<roll.length; i++){
  return freqs;
  //Count the frequencies of each number (1..NUM_SIDES) in
  //the given dice roll, returning the result as a array of
  //NUM_SIDES integers. Note that freqs[0..5] are the frequencies
  //of 1..6. The dice show 1-6 but subscripts must go 0-5.


int maxOfAKind(int[] freqs){


  //Find and return the largest integer in an array of integers.

not sure what to put under maxOfAKind


  • edited December 2017

    Sorry, here are the constants

    final int NUM_SIDES=6;   //Sides on the dice
    final int NUM_DICE=5;    //The number of dice used
  • Obviously homework.

    Write down, in sentences, how you'd find the highest number in a list of numbers.

  • edited December 2017
     * Max Value in Array (v1.0.1)
     * GoToLoop (2017/Dec/01)
     * not-sure-what-to-put-to-get-largest-integer-in-this-array#Item_3
    void setup() {
      println(maxOfAKind(4, 8, 3, 0, 9, 2));
    // Find and return the largest integer in an array of integers:
    @ SafeVarargs static final int maxOfAKind(final int... arr) {
      int max = Integer.MIN_VALUE;
      if (arr != null)  for (final int i : arr)  if (i > max)  max = i;
      return max;
  • Or just wait until gotoloop does it for you. That way you learn nothing but hey...

Sign In or Register to comment.