After the list, sum, average, max and min have been printed, ask the user to enter a value. Then print the id
of each salesperson who exceeded that amount, and the amount of their sales. Also print the total number of
salespeople whose sales exceeded the value entered.
The bold is what i dont know how to do.

System.out.println("\nTotal sales: " + sum);
         System.out.println("Average sales: " + average);
         System.out.println("\nSalesperson " + minNum + " had the lowest sale with $" + minSale);
         System.out.println("Salesperson " + maxNum + " had the highest sale with $" + maxSale);
      
         System.out.println("--------------------");
         System.out.println("Enter a salevalue");
         int saleValue = scan.nextInt();
      //Its here I want to have the code for the problem above
      
      }
   }

You would need to post the rest of your code for anyone to help you out with that piece.

Maybe I was a little wrong about what I had to do.. It is in the chapter arrays anyway.
Then print the id of each salesperson who exceeded that amount, and the amount of their sales. Also print the total number of salespeople whose sales exceeded the value entered.
This is what i have:

// ****************************************************************
// 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, average;
      
         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;
         int maxNum = 0;
         int minNum = 0;
         int maxSale = sales [0];
         int minSale = sales[0];

			
         for (int i=0; i<sales.length; i++)
         {
            System.out.println(" " + i + " " + sales[i]);
            sum += sales[i];
         
            if(sales[i] > maxSale)
            {
               maxSale = sales[i];
               maxNum = i;
            }
            if(sales[i] < minSale)
            {	
               minSale = sales[i];
               minNum = i;
            }
         }
         average = sum/SALESPEOPLE;
      
      
         System.out.println("\nTotal sales: " + sum);
         System.out.println("Average sales: " + average);
         System.out.println("\nSalesperson " + minNum + " had the lowest sale with $" + minSale);
         System.out.println("Salesperson " + maxNum + " had the highest sale with $" + maxSale);
      
         System.out.println("--------------------");
         System.out.println("Enter a salevalue");
    
	      int saleValue = scan.nextInt();
			int saleExceed;
        
		   for (int i=0; i<sales.length; i++)	
			
				if (sales[i] > saleValue)
				{
					System.out.println("test " + " " + sales[i]);
  		    	}
      }
   }

Edited 6 Years Ago by qariella: n/a

Became this:

int saleValue = scan.nextInt();
        
			for (int i=0; i<sales.length; i++)	
			
				if (sales[i] > saleValue)
				{
				System.out.println("Salesperson " + i + " exceeds a salevalue of "
				+ saleValue + " with a sale on " + sales[i]);
  		    	}
This question has already been answered. Start a new discussion instead.