0

Ok, I have a homework problem that I'm needing some help with.

The program has to

Allow the user to specify the number of integers to be inputted into the array

read a data set of number of integers into the array

Determine the sum

find the largest integer

and deturmine how many times the largest number is in the array.

I'm having the most trouble with find the largest number, I know how to do it with a really long if, else statement, but there has to be an easier way.

```
import java.util.Scanner;
public class lab10a_Killackey {
public static void main(String args[])
{
Scanner input = new Scanner (System.in);
int dataset;
int [] integers = new int[dataset] ;
int total = 0;
System.out.println("How many integers are in the data set? ");
dataset = input.nextInt();
System.out.println("Enter the integers in the dataset 1 per line");
int [dataset] integers = {input.nextInt()};
if ( dataset != 0)
{
for (int number: integers );
total += number;
System.out.printf("Sum of integers is: %d\n",total);
for (int number: integers);
//This is where the code for finding the largest integer is supposed to be!
for (int largest = 1; largest<= dataset; dataset++ )
System.out.printf("This number appered %d times\n");
}
else
System.out.print("The dataset is empty");
}
}
```

*Edited 3 Years Ago by Reverend Jim*: Fixed formatting