My name is Dragon, I am a student of Java and yes, technically this was an assignment. However, I am not turning this one in, I have re-written another one for the assignment. However, I am sure the reason this one didn't work was something simple, I would like to know what it was so I can do better next time.
The idea was to make an array of sales people, assign an amount of sales to each and then to compare two of them and tell the person with fewer sales how many they needed to reach the other person.
What I wanted to do was to put in a random number generator with minimum and maximum limits that would simply assign a number at random to each person you asked for, then use that value to do everything else. It doesn't matter if the sales person you ask for is actually in the list, the main point is the math and to be able to use methods.
I can get the random number generator to work, I can get it to send that value to the commissionCalculator method to determine if they get a raise in commission. I can send that value to the comparisonCalculator to determine who has more sales and what the difference is.
I can't get it to call that number and display the results on the screen.
I appreciate any help I can get.
import java.util.Arrays; //Imports the Arrays class
import java.util.Scanner; //Imports the Scanner class
import java.text.NumberFormat; //Imports the NumberFormat class to format to currency
public class DragonWoodPRG420Week4
{
static Scanner sc = new Scanner(System.in);
public static void main(String[] args)
{
String totalSalesStr; //Declares the string variable for the sales input
String firstPerson; //Sets the variable for user input
String secondPerson; //Sets the variable for user input
NumberFormat annualTotal = NumberFormat.getCurrencyInstance();
double firstPersonSales = commissionCalculator();
double secondPersonSales = commissionCalculator();
double totalSalesDifference = comparisonCalculator();
System.out.println("The possible sales people are: \n");
String[] salesPeople = {"Jack Dickerhoff", "Joseph Montana", "Magan Sander-Gaines", "Sean Wiles", "Dragon Wood"};
for (String salesPerson : salesPeople)
{
System.out.println(salesPerson);
}
System.out.println("\nPlease enter the name of the first sales person: ");
firstPerson = sc.nextLine();
System.out.println("\nThe total annual sales for this person is: " + annualTotal.format(firstPersonSales) +".");
System.out.println("\nPlease enter the name of the second sales person: ");
secondPerson = sc.nextLine();
System.out.println("\nThe total annual sales for this person is: " + annualTotal.format(secondPersonSales) +".");
}
public static double commissionCalculator()
{
double salesTarget = 156000.00; //Sets the sales target to $156,000.00
double salesThresh = 0.7; //Sets the sales threshold to 70%
double accelFactor = 1.5; //Sets the acceleration factor to 1.5
double fixedSalary = 50000.00; //Sets annaul salary amount
double commissionRate = 0.12; //Sets the commission rate to 12%
double totalPay; //Declares the variable for the total pay outputs
double totalCommission; //Declares the variable for the commission outputs
double minSales = 100000; //Sets the minimum number of sales
double maxSales = 200000; //Sets the maximum number of sales
double totalSales = getTotalSales(minSales, maxSales);
if (totalSales >= (salesTarget * salesThresh))
{
if (totalSales > salesTarget)
{
totalCommission = ((commissionRate * totalSales) * accelFactor);
totalPay = totalCommission + fixedSalary;
return totalPay;
}
else
{
totalCommission = commissionRate * totalSales;
totalPay = totalCommission + fixedSalary;
return totalPay;
}
}
else
{
totalPay = fixedSalary;
return totalPay;
}
}
public static double getTotalSales(double minSales, double maxSales)
{
return (double)(Math.random() * (maxSales - minSales + 1)) + minSales;
}
public static double comparisonCalculator(double firstPersonSales, double secondPersonSales)
{
double salesFirst = firstPersonSales;
double salesSecond = secondPersonSales;
double salesDifference;
if (salesFirst != salesSecond)
{
if (salesFirst > salesSecond)
{
salesDifference = salesFirst - salesSecond;
return salesDifference;
}
else
{
salesDifference = salesSecond - salesFirst;
return salesDifference;
}
}
else
{
salesDifference = 0;
return salesDifference;
}
}
}
Thanks,
Dragon Wood

New Topic/Question
Reply



MultiQuote







|