Programming Reusability

New_Network
WK4SalesPeople4.java

package wk4.salespeople; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class WK4SalesPeople { public static void main(String[] args) { // this method will prompt the user to input how many salespeople are being compared. public int salesPeople(int totalPeople) throws IOException { String input; boolean done = false; System.out.println("How many salespeople are being compared? (Minimum of two)"); BuffereddReader dataIn = new BufferedReader(new InputStreamReader System.in)); input = dataIn.readLine(); // some error checking try { totalPeople = (int) Double.parseDouble(input); if (totalPeople <= 0) throw new NumberFormatException(); else done = true; } catch(NumberFormatException e) System.out.println("You must enter a value greater than or equal to two"); } return totalPeople; } // this method will prompt the user to enter sales names public String[] salesName(String[] salesName, int totalPeople) thros IOException throws IOException throws IOException { int x = 0; for (x=0; x < totalPeople; x++) { System.out.println("Please enter a name for salesperson # " + (x+1)); BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in)); salesName[x] = dataIn.readLine() } return salesName; } // This method will prompt the user to enter annual sales for each person and store the values into an array. public int[] salesArray(int[] salesComparison, int[] sales, int totalPeople, String[] salesName) throws IOException { String input2; boolean done = false; int start; for (start = 0, start < totalPeople; start ++) { System.out.println("Enter total annual sales for " + salesName[start] + ": "); BufferedReader dataIn = new BUfferedReader(new InputStreamReader(System.in)); input2 = dataIn. readline(); try { sales[start] = (int) DoubleparseDouble(input2); salesComparison [start] = sales[start]; if (sales[start] < 0) throw new NumberFormatException; else done = true; } catch(NumberFormatException e) { System.out.println("You cannot have negative sales. Try again!"); start = start-1; } return sales; } } // this method will display some basic information about each sales person. public void salespersonInfo (String [] salesName, int totalPeople, int salary, int [] sales) { int infoStart; for (infoStart = 0, infoStart < totalPeople; infoStart++) System.out.println("---------------------------"); System.out.println("/t" + salesName[infoStart]); System.out.println("--------------------------"); System.out.print("Salary: " + salary); salesCalc displayCalc = new salesCal(); displayCalc.salesCalculation(sales, salary, infoStart); } } }