
JAVA PROGRAM TO ACCEPT 5 COMMAND LINE ARGUMENTS AND FIND THE SUM OF THAT FIVE.ALSO FIND OUT LARGEST AMONG THAT 5

Hi Friend,
Try the following code:
import java.util.*;
class FindSumAndLargest{
public static void main(String[] args){
int max = Integer.MIN_VALUE;
int sum=0;
System.out.println("Enter 5 numbers:");
Scanner input=new Scanner(System.in);
for(int i=1;i<=5;i++){
int num=input.nextInt();
if (num > max) {
max = num;
}
sum+=num;
}
System.out.println("Sum of all Numbers is: "+sum);
System.out.println("Largest Number is: "+max);
}
}
Thanks

this is not command line argument you using only scanner class,,only do it by string argument.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.