Write a program that will prompt for the user to input an integer. Continue to take input until a sentinal
value is given. (I recommend a negative number) Once input is complete, print out the mean, min, and the max
of the inputted numbers.
You'll need to use an infinite loop and break it when you get the sentinal value. You will also need variables
for sum, mean, min, and max. Stick with the integer type throughout the program.
If any one can steer me in the right direction, I'd greatly appreciate it. Honestly I just don't remember ever remember going over anything dealing with user input at the command prompt.
* Ahhh, I do have something in my notes (my last class was 2 weeks ago, gimme a break) but it still doesn't make sense to me
Input java.util.scanner;
Scanner input = new scanner (System.in);
Int x;
X = input.next Int();
while(true)
{
//take input
If(sentinel_value== -1)
{
Break
}
//test to see if it’s the min
//test to see if it’s the max
//add it to the sum
//increment my counter
}
Print
Determine mean?Now I was talking to my friend that's in the class with me over the break and he said he couldn't get his to work but that was as far as I got talkin with him.
This post has been edited by Honda_Boy: 08 March 2008 - 09:13 PM

Sign In »
Register Now!
Help


Back to top
MultiQuote
