public class Sales
{
public static void main(String[] args)
{
final int SALESPEOPLE = 5;
int[] sales = new int[SALESPEOPLE];
int sum;
int max;
int min;
int bestSeller = 0;
int worstSeller = 0;
Scanner scan = new Scanner(System.in);
for (int i=0; i<sales.length; i++)
{
System.out.print("Enter sales for salesperson " + i + ": ");
sales[i] = scan.nextInt();
}
System.out.println("\nSalesperson Sales");
System.out.println("--------------------");
sum = 0;
min = sales[0];
max = sales[0];
for (int i=0; i<sales.length; i++)
{
System.out.println(" " + i + " " + sales[i]);
sum += sales[i];
if (max < sales[i])
{
max = sales[i];
}
if (min > sales[i])
{
min = sales[i];
}
}
System.out.println(min);
System.out.println(max);
System.out.println("Average sales: " + sum / SALESPEOPLE);
System.out.println("\nTotal sales: " + sum);
}
}
basically i would need to declare to variables (bestSeller, worstSeller) and then print out which seller it is like:
System.out.println("Salesman " + bestSeller + " has the greatest sales at " + max);
Example print: Salesman 4 has the greatest sales at 1000.
try not to just give the answer, and rather just a clue at where to start if possible. thanks

New Topic/Question
Reply



MultiQuote






|