
import java.util.Scanner;

public class FindMaxForLoop {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		//ask how many values, n
		System.out.print("How many values? ");
		int n = input.nextInt();
		
		//largest so far
		double max = Double.NEGATIVE_INFINITY;
		
		//repeat n times
		for(int i = 1; i <= n; i++) {
			//get the next value from the user
			System.out.print("Enter a value: ");
			double value = input.nextDouble();
			
			if(value > max) {
				//replace max
				max = value;
			}
		}
		System.out.printf("The largest value was %f\n", max);
	}

}
