After I ask the user to enter a number here
System.out.println("Enter a number");
number = scan.nextInt();
I would like print the id of each salesperson that exceeded that value and the amount of their sales. I Also want to print the total number of salespeople whose sales exceeded the value entered. So I would think I would need some kind of for loop and several print statements. This is what I am thinking for my for loop.
for (int i=0; number<i; i++)
Line 1 to line 56 is good. After that is where I am trying to put my for loop.

//****************************************************************
// Sales.java
//
// Reads in and stores sales for each of 5 salespeople.  Displays
// sales entered by salesperson id and total sales for all salespeople.
//
// ****************************************************************
import java.util.Scanner;

public class Sales
{
    public static void main(String[] args)
    {
	final int SALESPEOPLE = 5;
	int[] sales = new int[SALESPEOPLE];
	int sum;

	Scanner scan = new Scanner(System.in);

	for (int i=0; i<sales.length; i++)
	    {
		System.out.print("Enter sales for salesperson " + (i+1) + ": ");
		sales[i] = scan.nextInt();
	    }

	System.out.println("\nSalesperson   Sales");
	System.out.println("--------------------");
	sum = 0;
        int maximum = sales[0];
        int minimum  = sales[0];
        int a=1, b=1;
	for (int i=0; i<sales.length; i++)
	    {
		if(maximum < sales[i])
                {
                    maximum = sales[i];
                    a = i+1;
                }
                if(minimum > sales[i])
                {
                    minimum = sales[i];
                    b = i+1;
                }
                System.out.println("     " + (i+1) + "         " + sales[i]);
		sum += sales[i];
	    }

	System.out.println("\nTotal sales: " + sum);
        System.out.println("The average sale is: " + sum / SALESPEOPLE );
        System.out.println("The maximum sale is: " + maximum + " by Salesperson " + a );
        System.out.println("The minimum sale is: " + minimum + " by Salesperson " + b );

        int number;
        System.out.println("Enter a number");
        number = scan.nextInt();
        System.out.println("The number you entered is " +number);
        System.out.println(sales);


        for (int i=0; number<i; i++)
	    {
		System.out.println(+ sales[i]);
	    }
        
        //if(number < sales[i])
            //System.out.println( + SALESPEOPLE);


    }
}

After I ask the user to enter a number here
System.out.println("Enter a number");
number = scan.nextInt();
I would like print the id of each salesperson that exceeded that value and the amount of their sales. I Also want to print the total number of salespeople whose sales exceeded the value entered. So I would think I would need some kind of for loop and several print statements. This is what I am thinking for my for loop.
for (int i=0; number<i; i++)
Line 1 to line 56 is good. After that is where I am trying to put my for loop.

//****************************************************************
// Sales.java
//
// Reads in and stores sales for each of 5 salespeople.  Displays
// sales entered by salesperson id and total sales for all salespeople.
//
// ****************************************************************
import java.util.Scanner;

public class Sales
{
    public static void main(String[] args)
    {
	final int SALESPEOPLE = 5;
	int[] sales = new int[SALESPEOPLE];
	int sum;

	Scanner scan = new Scanner(System.in);

	for (int i=0; i<sales.length; i++)
	    {
		System.out.print("Enter sales for salesperson " + (i+1) + ": ");
		sales[i] = scan.nextInt();
	    }

	System.out.println("\nSalesperson   Sales");
	System.out.println("--------------------");
	sum = 0;
        int maximum = sales[0];
        int minimum  = sales[0];
        int a=1, b=1;
	for (int i=0; i<sales.length; i++)
	    {
		if(maximum < sales[i])
                {
                    maximum = sales[i];
                    a = i+1;
                }
                if(minimum > sales[i])
                {
                    minimum = sales[i];
                    b = i+1;
                }
                System.out.println("     " + (i+1) + "         " + sales[i]);
		sum += sales[i];
	    }

	System.out.println("\nTotal sales: " + sum);
        System.out.println("The average sale is: " + sum / SALESPEOPLE );
        System.out.println("The maximum sale is: " + maximum + " by Salesperson " + a );
        System.out.println("The minimum sale is: " + minimum + " by Salesperson " + b );

        int number;
        System.out.println("Enter a number");
        number = scan.nextInt();
        System.out.println("The number you entered is " +number);
        System.out.println(sales);


        for (int i=0; number<i; i++)
	    {
		System.out.println(+ sales[i]);
	    }
        
        //if(number < sales[i])
            //System.out.println( + SALESPEOPLE);


    }
}

I think by number you mean to get the information about salespersons whoose sales value is more than the input value
simply add following lines after line 56

int salescount=0;
System.out.println("ID"+"\tSales");
for(int i=0;i<sales.length;i++)
{
if(sales[i]>number)
{
System.out.println(i+"\t"+sales[i]);
salescount++;
}
}
System.out.println("Number of people who exceeded the required value are"+salescount);
This article has been dead for over six months. Start a new discussion instead.