{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

smallestNumber

# smallestNumber - "78 and 56 is" smallest(23 78 56...

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

import java.util.*; import java.lang.*; import java.io.*; import java.text.*; import java.math.*; import java.text.DecimalFormat; import java.lang.String; // Jeremy Debruce //3/28/2009 // Programming Exercise ch9 Pro. 2 / public class smallestNumber { public static void main(String[] args) { System.out.println("*********************************************"); System.out.println("* The purpose of this program is to *"); System.out.println("* return the smallest the number of the *"); System.out.println("* array using a method *"); System.out.println("* *"); System.out.println("*********************************************"); int[] numberList = {23, 45, 89, 34, 92, 36, 90, 120, 97, 23, 90, 89}; System.out.println("Line 2: The smallest of 5 " + "and 10 is " + smallest(5, 10)); System.out.println("Line 3: The smallest of 23, "

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: + "78, and 56 is " + smallest(23, 78, 56)); System.out.println("Line 4: The smallest of 93, " + "28, 83, and 66 is " + smallest(93, 28, 83, 66)); System.out.println("Line 5: The smallest of 22, " + "12, 56, 78, " + "\n " + "98, 25, 78, 23 and 36 is " + smallest(22, 12, 56, 78, 98, 25, 78, 23, 36)); System.out.println("Line 6: The smallest " + "number in numList is " + smallest(numberList)); System.out.println("Line 7: A call to the method " + "smallest with an empty \n" + " parameter " + "list returns the value " + smallest()); } public static int smallest(int . .. numList) { int min; int index; if (numList.length != 0) { min = numList[0]; for (index = 1; index < numList.length; index++) { if (min > numList [index]) min = numList [index]; } return min; } return 0; } }...
View Full Document

{[ snackBarMessage ]}