import java.util.Scanner;
public class Simple
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("How many number?");
int numNumber = scanner.nextInt();
int sum = 0;
int []numbers=new int[numNumber];
int highest=numbers[0];
int lowest=numbers[0];
for(int i = 0;i< numbers.length ; i++)
{
System.out.println("Please input number" + i + ":");
numbers[i]= scanner.nextInt();
sum += numbers[i];
for(int j=0; j<numbers.length;j++)
{
if(numbers[j]>highest)
{
highest=numbers[j];
}
else if(lowest>numbers[j])
{
lowest=numbers[j];
}
}
}
System.out.println("Sum of the number is" + sum);
double average = (double)sum/numNumber;
System.out.println(" The average is" + average);
System.out.println("The largest number is" + highest);
System.out.println("The smallest number is" + lowest);
}
}
why the lowest number is zero?..
is there anything wrong with the array code?..