Java help!! Programming questions

Nov 16th, 2013
SoccerBoss
Category:
Programming
Price: $20 USD

Question 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.


Tutor Answer

(Top Tutor) Daniel C.
(997)
School: UC Berkeley
PREMIUM TUTOR

Studypool has helped 1,244,100 students

8 Reviews


Summary
Quality
Communication
On Time
Value
tinytim47
Nov 30th, 2016
" Wow this is really good.... didn't expect it. Sweet!!!! "
Five Star Tutor
Nov 21st, 2016
" Outstanding Job!!!! "
mixedballz
Nov 17th, 2016
" excellent work as always thanks for the help "
lilmoe415
Nov 8th, 2016
" Thank you, Thank you, for top quality work, this is your guy!! "
darnay
Oct 25th, 2016
" The best tutor out there!!!! "
dontuwannaknow
Oct 16th, 2016
" Excellent work as always thanks so much "
SjSurvivor143
Oct 3rd, 2016
" Thanks for the help. "
Joemoe
Sep 19th, 2016
" <3 it, thanks for saving me time. "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1820 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors