I am working on a code to read N user input numberb and then display the largest and the smallest of them. The inesgers have to fall in between -999999 and 999999, I have been tinkering with this for a few days now and can't seem to figure out how to make it work, here is my code

import java.util.*;
public class LabThree
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
int totaldoubles;
int total, nextnum, max, min;
String answer;
do
{
System.out.println();
System.out.println("Enter a list of nonnegative integers");
System.out.println("When you are finished with the list, enter 1000000");
System.out.println();
System.out.println("I will tell you the largest and smallest integer");
totaldoubles = 0 ;
total = 0;
nextnum = keyboard.nextDouble();
max = nextnum;
min = nextnum;
while (nextnum != 1000000)
{
total = total + nextnum;
totaldoubles++;
nextnum = keyboard.nextDouble();
if (nextnum > max)
max = nextnum;
else if (nextnum < min)
min = nextnum;
}
if (totaldoubles >= -999999) System.out.println("The smallest number was: "+min);
System.out.println("The largest number was: " + max);
answer = keyboard.next();
}
}
}

I'd be happy to look at this, if you tell me what I'm looking for. What is it doing that it's not supposed to be doing, or not doing that it should be doing?

Ive said what Im looking for, and now its not doing anything I cant get it to compile anymore

Please copy full text of error message and paste it here. Here is a sample:

TestSorts.java:138: cannot find symbol
symbol  : variable var
location: class TestSorts
         var = 2;
         ^

...

LabThree.java:35: while expected
}
^
LabThree.java:37: illegal start of expression
}
LabThree.java:37: reached end of file while parsing
}

Okay, simple enough. "while expected" means it wants a "while" there. If you follow the curly braces back, you see that you start a do { } at line 10, and at line 35 you close out the statement block but don't tell it what the exit condition for the loop is.
The stuff at line 37 looks like you've got some sort of control character after the last closing brace, which is giving your compiler trouble.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.