Java help!! Programming questions

User Generated

pfn062080

Programming

Description

I need some help with my program:


import java.util.Scanner;

public class Commission {

    private static double sales;

public static void main(String[] args) {

 //declare variables for arrary

    String salesPerson1;

    String salesPerson2;

   

   

    //number of employees to compare, and initialize array

         int[] aTotal = new int[2];

       

         //new scanner input

         Scanner keyboard = new Scanner(System.in);

       

         //get salesperson1 name

         System.out.println("What is your first salesperson's name?");

         salesPerson1 =  keyboard.nextLine();

       

         //get salesperson1 sales total

         System.out.println("What was their sales total for the year?");

         aTotal[0] = (int) keyboard.nextDouble();

       

         //get salesperson2 name

         System.out.println("What is your second salesperson's name?");

         salesPerson2 = keyboard.nextLine();

       

         //get salesperson2 sales total

         System.out.println("What was their sales total for the year?");

         aTotal[1] = (int) keyboard.nextDouble();

       

         //This part of the array needs to reference back to the commission

  //Loop for setting name and annual sales of salesperson

       do

       {  

           //Create an Salesperson object

           Salesperson sPerson = new Salesperson();

           //Set salesperson's name

           System.out.println("Enter salesperson name");

           String name = keyboard.nextLine();

           sPerson.setName(name);

           //End while loop

           if (name.equalsIgnoreCase("Done"))

               break;                    

           //Set annual sales for salesperson

           System.out.println("Enter annual sales for salesperson");

           sales = keyboard.nextDouble();

           sPerson.setSales(sales);          

           //To add Salesperson object to ArrayList

           cArray.add(sPerson);

           //Consume line

           keyboard.nextLine();    

       }

       while (true);

       //Display ArrayList

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

       for (int index = 0; index < cArray.size(); index++)

       {

           Salesperson sPerson = (Salesperson)cArray.get(index);

           System.out.println();

           System.out.print("Salesperson " + (index + 1) +

                            "\n Name: " + sPerson.getName() +

                            "\n Sales: " + (arrayL.format(sPerson.getSales())) +

                            "\n Commission Earned: " + 

                            (arrayL.format(sPerson.getComm())) +

                            "\n Total Annual Compensation: " 

                            + (arrayL.format(sPerson.getAnnComp())) + "\n\n");

       }

         // calcs to add data to the array        

         for (int counter=0; counter < aTotal.length; counter++)

         {

             System.out.printf("Salesperson: Total", counter, aTotal[counter]);

         }

             System.out.println("Salesperson" + "\t\t" + "Total");

             //System.out.println("--------------------------------");

       

}

    private static class Salesperson {

        public Salesperson() {

        }

        private void setName(String name) {

            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        }

        private void setSales(double sales) {

            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        }

    }

    private static class DecimalFormat {

        public DecimalFormat() {

        }

    }

}



//THIS IS WHAT I NEED IT TO DO...


Write a simple commission calculation 


The application will now compare the total annual compensation of at least two salespersons.

·It will calculate the additional amount of sales that each salesperson must achieve to match or exceed the higher of the two earners.

·The application should ask for the name of each salesperson being compared.


User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer


Anonymous
I use Studypool every time I need help studying, and it never disappoints.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags