Sales - " + (i+1) + "\t\t" + sales[i]); sum...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// **************************************************************************** // Sales.java // // Reads in and stores sales for each of any number of 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) { int numSalesPeople; Scanner scan = new Scanner (System.in); System.out.print ("Enter the number of sales people: "); numSalesPeople = scan.nextInt(); int[] sales = new int[numSalesPeople]; int sum; int maxSales, minSales; int maxSalesPerson, minSalesPerson; int amount; int numOver; 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; maxSales = 0; maxSalesPerson = 0; minSales = sales[0]; minSalesPerson = 0; for (int i=0; i<sales.length; i++) { System.out.println("
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: " + (i+1) + "\t\t" + sales[i]); sum += sales[i]; if (sales[i] > maxSales) { maxSales = sales[i]; maxSalesPerson = i; } if (sales[i] < minSales) { minSales = sales[i]; minSalesPerson = i; } } System.out.println("\nTotal sales: " + sum); System.out.println("Average sale: " + sum/sales.length); System.out.println("Maximum sales " + maxSales + " by Salesperson " + (maxSalesPerson+1)); System.out.println("Minimum sales " + minSales + " by Salesperson " + (minSalesPerson+1)); // Get a value from the user System.out.println(); System.out.print("Enter a sales amount: "); amount = scan.nextInt(); numOver = 0; System.out.println ("\nList of sales over " + amount); System.out.println(); System.out.println ("Salesperson Sales"); for (int i = 0; i < sales.length; i++) { if (sales[i] > amount) { System.out.println(" " + (i+1) + "\t\t\t" + sales[i]); numOver++; } } System.out.println(); System.out.println (numOver + " salespeople had sales over " + amount); } }...
View Full Document

This note was uploaded on 03/18/2010 for the course CPSC 1301 taught by Professor Eanes during the Spring '10 term at Middle Georgia State College.

Page1 / 2

Sales - " + (i+1) + "\t\t" + sales[i]); sum...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online