LargestNumber

LargestNumber - + largest(22.5, 12.34, 56.34, 78, 98.45,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//Program: Largest of a set of numbers / import java.util.*; i public class LargestNumber { public static void main(String[] args) { double[] numberList = {23, 45.5, 89, 34, 92.78, 36, 90, 120.89, 97, 23, 90, 89}; //Line 1 System.out.println("Line 2: The larger of 5.6 " + "and 10.8 is " + largest(5.6, 10.8)); //Line 2 System.out.println("Line 3: The largest of 23, " + "78, and 56 is " + largest(23, 78, 56)); //Line 3 System.out.println("Line 4: The largest of 93, " + "28, 83, and 66 is " + largest(93, 28, 83, 66)); //Line 4 System.out.println("Line 5: The largest of 22.5, " + "12.34, 56.34, 78, " + "\n " + "98.45, 25, 78, 23 and 36 is "
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: + largest(22.5, 12.34, 56.34, 78, 98.45, 25, 78, 23, 36)); //Line 5 System.out.println("Line 6: The largest " + "number in numList is " + largest(numberList)); //Line 6 System.out.println("Line 7: A call to the method " + "largest with an empty \n" + " parameter " + "list returns the value " + largest()); //Line 7 } public static double largest(double . .. numList) { double max; int index; if (numList.length != 0) { max = numList[0]; for (index = 1; index < numList.length; index++) { if (max < numList [index]) max = numList [index]; } return max; } return 0.0; } }...
View Full Document

This note was uploaded on 06/17/2011 for the course COMP 2301 taught by Professor Staff during the Spring '10 term at Kennesaw.

Page1 / 2

LargestNumber - + largest(22.5, 12.34, 56.34, 78, 98.45,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online