Hi, for the life of me I can't solve this problem. I've solved problems far harder, but this is just baffling me.
The problem:
Write a program which reads a sequence of integers from the standard input (the
keyboard) and prints the largest value read to the standard output (the screeen).
My current code is as follows:
import java.util.*;
public class Largest
{
public static void main (String [] args)
{
System.out.println("Enter a sequence of numbers");
Scanner in = new Scanner(System.in);
int count = 0;
while(in.hasNextLine() )
{
int nums = in.nextInt();
if(nums > count)
{
count = nums;
count++;
System.out.println(count);
}
}
}
}
But this doesn't seem to work.
If anyone can offer some help that'd be great!