Write a program that passes an unspecified number of integers from command line and displays their total. Sample Run 1 command>java 1 2 3 4 5 The total is 15 Sample Run 2 command>java 1 9 1 1 1 The total is 13 Class Name: Exercise07_21

Respuesta :

Using the computational language in JAVA it is possible to write a code that at least passes an unspecified number of integers

Writing code in JAVA

class Exercise07_21

{

public static void main(String args[])

{

int sum=0;

for(int i=0;i<args.length;i++)

sum=sum+Integer.parseInt(args[i]);//converting string to integer and then adding it with sum variable and storing back in sum

System.out.println("The total is "+sum);//printing the sum

}

}

See more about JAVA code at brainly.com/question/12975450

#SPJ1

Ver imagen lhmarianateixeira