import java.util.Scanner;
public class Sales
{
public static void main(String[] args)
{
int[] sales = new int[5];
int sum;
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 max = 0;
int min = sales[0];
for (int i=0; i<sales.length; i++)
{
System.out.println(" " + i + " " + sales[i]);
sum += sales[i];
if (sales[i] > max)
{
max = sales[i];
}
if (sales[i] < min)
{
min = sales[i];
}
}
System.out.println("\nTotal sales: " + sum);
System.out.println("Average sales: " + (sum/5));
System.out.println("Most Sales: " + max);
System.out.println("Least Sales: " + min);
System.out.println();
System.out.print("Enter a filter value: ");
int value = scan.nextInt();
System.out.println();
System.out.println ("Sales Above "+value);
System.out.println();
System.out.println("Salesperson Sales");
System.out.println("--------------------");
for (int i = 0; i < sales.length; i++)
{
if (sales[i] >= value)
{
System.out.println();
System.out.println(" " + i + " " + sales[i]);
}
}
}
}
public class Sales
{
public static void main(String[] args)
{
int[] sales = new int[5];
int sum;
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 max = 0;
int min = sales[0];
for (int i=0; i<sales.length; i++)
{
System.out.println(" " + i + " " + sales[i]);
sum += sales[i];
if (sales[i] > max)
{
max = sales[i];
}
if (sales[i] < min)
{
min = sales[i];
}
}
System.out.println("\nTotal sales: " + sum);
System.out.println("Average sales: " + (sum/5));
System.out.println("Most Sales: " + max);
System.out.println("Least Sales: " + min);
System.out.println();
System.out.print("Enter a filter value: ");
int value = scan.nextInt();
System.out.println();
System.out.println ("Sales Above "+value);
System.out.println();
System.out.println("Salesperson Sales");
System.out.println("--------------------");
for (int i = 0; i < sales.length; i++)
{
if (sales[i] >= value)
{
System.out.println();
System.out.println(" " + i + " " + sales[i]);
}
}
}
}
(0) Comments
Post a Comment