Rutgers University CS 111 LargestOfFive.java
/*************************************************************************
* Compilation: javac LargestOfFive.java
* Execution: java LargestOfFive 35 10 32 1 8
*
* @author:
*
* Takes five distinct integers as command-line arguments and prints the
* largest value
*
*
* % java LargestOfFive 35 10 32 1 8
* 35
*
* Assume the inputs are 5 d
...[Show More]
Rutgers University CS 111 LargestOfFive.java
/*************************************************************************
* Compilation: javac LargestOfFive.java
* Execution: java LargestOfFive 35 10 32 1 8
*
* @author:
*
* Takes five distinct integers as command-line arguments and prints the
* largest value
*
*
* % java LargestOfFive 35 10 32 1 8
* 35
*
* Assume the inputs are 5 distinct integers.
* Print only the largest value, nothing else.
*
*************************************************************************/
public class LargestOfFive {
public static void main (String[] args) {
int[] a = new int[5];
a[0] = Integer.parseInt(args[0]);
a[1] = Integer.parseInt(args[1]);
a[2] = Integer.parseInt(args[2]);
a[3] = Integer.parseInt(args[3]);
a[4] = Integer.parseInt(args[4]);
int maxVal = a[0];
for (int i=1; i<a.length; i++) {
if (maxVal < a[i]) {
maxVal = a[i];
}
[Show Less]