We worked on an algorithm to find the largest of five numbers. A possible algorithm is shown below:
Take one number at a time out of the container. Assume that the first number is the largest. If the second number is greater than the largest, the largest is now the second number. If the third number is greater than the largest, the largest is now the third number. If the fourth number is greater than the largest, the largest is now the fourth number. If the fifth number is greater than the largest, the largest is now the fifth number.
In drjava, write LargestOfFive.java that does the following:
Sample input/output:
Input 5 integers, space separated: 44 33 22 66 99 The largest is: 99
Link to program using alternative algorithm