Average - public static void main(String args int numArgs =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//****************************************************************** // Average.java // // Finds the average of the integer arguments in the command line. //****************************************************************** public class Average { //--------------------------------------------------- // Finds the average of the arguments passed to main // in the command line. //---------------------------------------------------
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public static void main (String args) { int numArgs = args.length; int sum = 0; for (int i = 0; i < numArgs; i++) sum += Integer.parseInt(args[i]); if (numArgs > 0) System.out.println ("The average of the arguments is " + (double)sum/numArgs); else System.out.println ("No arguments passed to main."); } }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online