I am trying to write a program and am in desperate need of help. The problem is as follows: Write a program to read in a list of nonnegative integers and to output the largest integer, the smallest integer, and the average of all the integers. The end of the input is indicated by the user entering a negative sentinel value. Note that the sentinel value is not used in finding the largest, smallest, or average. It is only an end marker. The average should be a value of type double, so that the average is computed with a fractional part. This is what I have so far:
import java.util.*;
public class largesttoSmallest
{
public static void main(String[] args)
{
//* Tosca J. Hudson//*
System.out.println("Enter some nonnegative intergers.");
System.out.println("Enter a negative interger after you have.");
System.out.println("entered the nonnegative intergers.");
int largest = 0;
int smallest = 0;
double largest, smallest, average;
Scanner keyboard = new Scanner(System.in);
number = keyboard.nextInt( );
while (integer variable is >= 0);
{
System.out.println();
}
System.out.println( );
System.out.println();
}
}
Software/Hardware used:
ASKED:
December 7, 2007 4:50 PM
UPDATED:
January 7, 2008 3:36 PM