LargestNumber - int count/loop control variable...

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

View Full Document Right Arrow Icon
//******************************************************** // Author D.S. Malik // // Program: Largest number // This program determines the largest number of a set of // 10 numbers. //******************************************************** / import java.util.*; i public class LargestNumber { static Scanner console = new Scanner(; public static void main(String[] args) { double num; //variable to hold the current number double max; //variable to hold the larger number
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int count; //loop control variable System.out.println("Enter 10 numbers:"); num = console.nextDouble(); //Step 1 max = num; //Step 1 for (count = 1; count < 10; count++) //Step 2 { num = console.nextDouble(); //Step 2a max = larger(max, num); //Step 2b } System.out.println("The largest number is " + max); //Step 3 } public static double larger(double x, double y) { if (x >= y) return x; else return y; } }...
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.

Ask a homework question - tutors are online