/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

/**

*

* @author Chuck

*/

importjava.text.DecimalFormat; //Allows use of Decimal formatting class.

importjava.util.Scanner; //Enables use of the Scanner class.

public class JavaProg {

public static void main(String[] args)

{

//Creates decimal formatting class object with monetary attributes.

DecimalFormatdecimalFormat = new DecimalFormat ("#,##0.00");

Scanner keyboard = new Scanner(System.in);

System.out.println("Do you wish to compare employee's sales numbers (1)? \n" +

"or do you wish to determine the total salary of an empployee (2)? \n" +

"Please enter either 1 or 2 to choose.");

int choice = keyboard.nextInt();

//If statement determines which part of the program will be run.

if (choice == 1)

{

//Statements to find out how many employees will be compared.

System.out.println("Please enter the total number of employees to be compared.");

intemployeeAmount = keyboard.nextInt();

//Declaration for variable size arrays for employee names and sales.

double[] employeeSales = new double[employeeAmount];

String[] employeeNames = new String[employeeAmount];

//User will input employee names and sales into the 2 arrays.

int count = 0;

while (count != employeeAmount)

{

System.out.println("Pleae enter the employee's name.");

keyboard.nextLine(); //Consumes keyboard-buffer remaining newline.

employeeNames[count] = keyboard.nextLine();

System.out.println("Please enter " + employeeNames[count] + "'s sales.");

employeeSales[count] = keyboard.nextDouble();

count++;

}

//Statements to determine which sales is the highest.

inthighIndex = 0;

doublehighSales = employeeSales[0];

for (int index = 1; index < employeeSales.length; index++)

{

if (employeeSales[index] > highSales)

{

highSales = employeeSales[index];

highIndex = index;

}

}

//Statements to display the difference in sales to the highest seller.

doublesalesDiff;

for (int index = 0; index < employeeSales.length; index++)

{

if (employeeSales[index] < highSales)

{

salesDiff = highSales - employeeSales[index];

System.out.println(employeeNames[index] + " must sell $"

+ decimalFormat.format(salesDiff) + " more to reach "

+ employeeNames[highIndex] + "'s sales of $"

+ decimalFormat.format(employeeSales[highIndex]) );

}

}

}

else if (choice == 2)

{

double sales;

System.out.println ("Please enter the amount of sales for this year.");

sales = keyboard.nextDouble();

//Declares the salary object variable with the default constructor.

SalaryObj salary = new SalaryObj();

//Print statement also calls the method to determine the salary from the salary object.

System.out.println("The total compensation for this year is $"

+ decimalFormat.format(salary.getSalary(sales)) );

System.out.println("\n\tSales\t\tSalary");

System.out.println("______");

// Declares the variables to setup the Loop for the table.

doubleSalesMax = sales * 1.5, SalesIncr = 5000;

//This loop displays the table of scaling potential sales using the salary object.

while (sales <= SalesMax)

{

sales += SalesIncr;

System.out.println("\t$" + decimalFormat.format(sales) + "\t$"

+ decimalFormat.format(salary.getSalary(sales)) );

}

}

elseSystem.out.println("Error, invalid choice. Please run again with a valid choice.");

}

}