Question: public class Sales2Test { public static void main( String args[] ) { Sales2 application = new Sales2(); application.calculateSales(); } // end main } // end
public class Sales2Test { public static void main( String args[] ) { Sales2 application = new Sales2(); application.calculateSales(); } // end main } // end class Sales2Test
..........................................................
public class Sales2 { public void calculateSales() { Scanner input = new Scanner( System.in ); // sales array holds data on number of each product sold // by each salesman double sales = new double[ 5 ][ 4 ];
System.out.print( "Enter sales person number (-1 to end): " ); int person = input.nextInt();
while ( person != -1 ) { System.out.print( "Enter product number: " ); int product = input.next(); System.out.print( "Enter sales amount: " ); double amount = input.nextDouble();
// error-check the input if ( person 5 && product >= 1 && product = 0 ) sales[ product - 1 ][ person - 1 ] += amount; else System.out.println( "Invalid input!" ); System.out.print( "Enter sales person number (-1 to end): " ); person = input.nextInt(); } // end while
// total for each salesperson double salesPersonTotal[][] = new double[ 4 ];
// display the table for ( int column = 0; column
System.out.printf( "%7s%14s%14s%14s%14s%10s ", "Product", "Salesperson 1", "Salesperson 2", "Salesperson 3", "Salesperson 4", "Total" );
// for each column of each row, print the appropriate // value representing a person's sales of a product for ( int row = 0; row
for ( int column = 0; column
System.out.printf( "%10.2f ", productTotal ); } // end for
System.out.printf( "%7s", "Total" );
for ( int column = 0; column
Section Ill Programming (20 POINTS) Program 1 (30 Points) The program in this section does not run properly. Fix all the compilation errors. compile successfully. Once the progra eliminate any logic errors that exist. The sample m compiles, compare the output to the sample output, and be once the program's code is corrected. output demonstrate what the program's output should Sample Output: Enter sales person number (1 to end): 1 Enter product number: 4 Enter sales amount: 1000 Enter sales person number (-1 to end): 2 Enter sales person number (-1 to end): 3 Enter sales person number (-1 to end): 4 Enter sales person number (-1 to end): -1 Enter product number: 3 Enter sales amount: 1998 Enter product number: 1 Enter sales amount: 2678 Enter product number: 1 Enter sales amount: 1554 roductSalesperson 1 Salesperson 2 Salesperson 3 Salesperson 4 Total 0.00 | a 0.00 2678.00 1554.004232.00 2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1998.00 0.001000.00 0.0000 1998.00 0.00 0.00 0.00 1000.00 0.00 0.00 0.00 1000.00 1998.00 2678.00 1554.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
