Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey I\'m having trouble writing this java programing question out. The question

ID: 3758472 • Letter: H

Question

Hey I'm having trouble writing this java programing question out. The question is below.

Create an application that allows you to store an array that acts as a database of any number of Salesperson objects up to 20. While the user decides to continue, offer three options: to add a record to the database, to delete a record from the database, or to change a record in the database. Then proceed as follow:

- If the user selects the add option, issue an error message if the database is full. Otherwise, prompt the user for an ID number. If the ID number already exists in the database, issue an error message. Otherwise, prompt the user for a sales value, and add the new record to the database.

- If the user selects the delete option, issue an error message if the database is empty. Otherwise prompt the user for an ID number. If the ID number does not exist, issue an error message. Otherwise, do not access the record for any future processing.

- If the user selects the change option, issue an error message if the database is empty. Otherwise prompt the user for an ID number. If the requested record does not exist, issue an error message. Otherwise, prompt the user for a new sales value, and change the sales value for the record.

After each option executes, display the updated database in ascending order by Salesperson ID number, and prompt the user to select the next action.

Explanation / Answer

import java.util.Scanner;

public class SalespersonArray

{

     

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 rference back to the commission

         // 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" + " " + "Total");

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

         

         

}

}

How do I call another method that calculates the comp for each

array ( [0] and [1]) from the salespersons entered totals?

P.S. this is on a timetable of July 20th.

The CommissionCalc program for the commission math:

public class CommissionCalc {

     

    // Declare fields for commission

    double salesTarget = 200000;

    double salary = 74000; // changed this to be 74,000

    double increment = 5000;

    double sales;

    double incentive;

    double accel;

    double bigSalary;

    double projSalesTotal;

    double projSales;

     

    // added the shell for a method

    public double calcComp(double sales){

        double commission = 0;

        // insert your logic here.

         

        double totalSalary = commission + salary;

        accel = commission * 1.25;

        bigSalary = accel + totalSalary;

        projSales = sales + 5000;

        projSalesTotal = (sales * 0.50) + sales;

                 

              

        return commission;

    }

     

    // Change to non static

    // Make an instance of class

    public void commission() {

        // Scanner /keyboard input

        Scanner keyboard = new Scanner(System.in);

        // Get users pay info

        System.out.println("What was your amount of sales for the year?");

        // Retrieve keyboard data

        sales = keyboard.nextDouble();

        // Math for commission

        double commission = 0.012 * sales;

                double totalSalary = commission + salary;

         

         

        // IF-ELSE statement

        if (sales >= 0.8 * salesTarget) {

             

            System.out.println("Your commission is " + commission + ".");

            System.out.println("Your salary plus commission is equal to "

                    + totalSalary + ".");

        } else

            System.out.println("your sales have not met the criteria"

                    + " to qualify you for a commission.");

        // IF-ELSE statement with accel factor

        if (sales >= salesTarget) {

            accel = commission * 1.25;

            System.out.println("The acceleration factor for meeting the sales"

                    + " target is 1.25.");

            System.out.println("The total of the accel factor is " + accel);

        }

        else

            System.out.print("You have not met the criteria to receive the "

                    + " accleration factor.");

        System.out.println(" your total salary for the year is " + totalSalary

                + ". ");

        // Display table

        System.out.println("Projected sales and totals.");

        System.out.println("Projected Sales Projected Totals.");

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

        // Display data

        for (projSales = sales; projSales <= projSalesTotal; projSales += 5000) {

            double calcComp;

            // the loop and then print the commission with the projected sales.

            System.out.println(projSales + " " + commission);

        }

    }

    // Main method

    public static void main(String[] args)

        {

        // [Paul] changed this to use OOP

        CommissionCalc calc = new CommissionCalc();

        calc.commission();

    }

}