b
Tuesday, February 23, 2016
Sales.java
Sales.java
//******************************************************************************************* Sales.java
//*******************************************************************************************
import java.util.Scanner;
public class Sales {
public static void main(String[] args){
final int SALESPEOPLE = 5;
int[] sales = new int[SALESPEOPLE];
int sum, randomValue, numGreater = 0;
int max = sales[0];
int min = sales[0];
int maxperson = 0;
int minperson = 0;
Scanner scan = new Scanner(System.in);
for (int i=0; i<sales.length; i++)
{
System.out.print("Enter sales for salesperson " + Integer.valueOf(i+1) + ": ");
sales[i] = scan.nextInt();
if(sales[i] > max){
max= sales[i];
maxperson = i;
}
if(sales[i] < min) {
min = Integer.MAX_VALUE;
minperson= i;
}}
System.out.println("\nSalesperson Sales");
System.out.println("--------------------");
sum = 0;
for (int i=0; i<sales.length; i++)
{
System.out.println(" " + Integer.valueOf(i+1) + " " + sales[i]);
sum += sales[i];
}
System.out.println("\nTotal sales: " + sum);
System.out.println("Average sales: " + sum/5);
System.out.println();
System.out.println("Salesperson " + Integer.valueOf(maxperson+1) + " had the most sales with " + max );
System.out.println("Salesperson " + Integer.valueOf(minperson+1) + " had the least sales with " + min);
System.out.println();
System.out.println("Enter any value to compare to the sales team: ");
randomValue = scan.nextInt();
System.out.println();
for(int r=0; r < sales.length; r++){
if(sales[r] > randomValue){
numGreater++;
System.out.println("Salesperson " + Integer.valueOf(r+1) + " exceeded that amount with " + sales[r]);
}}
System.out.println();
System.out.println("In total, " + numGreater + " people exceeded that value");
} }
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment