Exercise for reference variable and for static array
Program's goal: Create an array of 5 dice. Get the dice with random numbers. Sum the dice and print the dice and the total and the highest dice value. Constraint: The summation of the dice and the determination of the highest die needs to be done in one function. The printing must be done in the main method. Extra: sort the dice.
If the dice are 1,5,2,3,0
It will print:
1 5 2 3 0
Highest is 5
Sum is 11
Structure:
main method:
- create the dice array
- load the dice array with 5 random numbers
- create a variable to hold the highest number
- call the sum method
- print the array, highest and sum
sum method:
- In: pointer to highest value
- In: array of dice
- Out: int sum