This is my code so far
double amount;
int years;
double ans;
double extra = 400;
//Ask for amount
System.out.print("Please enter sales amount for the week: "); //Ask for amount
amount = MyInput.readDouble(); //Store amount
//Ask for years
System.out.print("Please enter the number of years the sales person has been with the company: ");
years = MyInput.readInt(); //Store amount
double commission = commission(amount);
double bonus = bonus(years);
System.out.println("Your weekly commission is $" + bonus );
}
public static double commission(double amount)
{
if (amount >= 5000) { //Calculate sales if amount entered is greater than or equal to 10001
return (amount * 0.10) + 400;
}
else if (amount >= 1000 ){
return (amount * .08);
}
else if (amount >= 1000){
return (amount * 0.08);
}
else if (amount >= 500 ){
return(amount * .05);
}
else { return 0.0;
}
}
public static double bonus(double commission, int years)
{
if (years >= 2) {
return (commission() baseSalary* years/100);
}
else { return 0.0;
}
}
}
I need to write three methods to 1st to calculate the commission which i've done and second to calculate bonus which checks for how man years the sales person has been there and they add the number of years they've been there to get weekly sales for instance
if (amount >= 5000 && years < 2){
ans = (amount * 0.10) + (baseSalary + 400);
But since I've already calculate commission which is half of this statement, how do I get commission and use it in my bonus method?

New Topic/Question
Reply




MultiQuote





|