Help with if-else-if staement
Hello all and thank you for your time for starters.
My question and problem is i need the applet to re-calculate the compensation in the second else if statement by 0.0375 not 0.025.
what and where am i wrong?
please ignore the comments they are not accurate.
Code:
// import java libraries
import java.text.NumberFormat;
import java.util.Scanner;
public class Math
{
// set and declare specific variables
double baseSalary = 60000; // set baseSalary
double annualSales; // set annualSales
double commission, below80 = 0.0, totalCompensation; // set commision to 0 beloew 80% objective
double startCompensation = 960000;
double commission80, above80 = 0.025, totalCompensation80; // set percentage after 80% is obtained
double additionalCompensation = 1200000;
double commission100, above100 = 0.0375, totalCompensation100; // set percent above 100% of Sales Goal
NumberFormat currency = NumberFormat.getCurrencyInstance(); // Get currency format from import
Scanner userInput = new Scanner( System.in ); // Create Scanner to obtain userInput from User
// Create userInput, calculator, and final display
public void Calculator()
{
// Get userInput and perform math calculations
System.out.print("Enter Salesman Annual Sales: $"); // Display message for userInput
annualSales = userInput.nextDouble(); // Read Salary from userInput
System.out.println(); // creates blank line
commission = annualSales * below80 ; // Total of annualSales below 80%
totalCompensation = commission + baseSalary ; // Total compensation
// Display Compensation below 80% of sales goal
if (annualSales < startCompensation) // Compare annualSales against 960000
{
System.out.println(" No extra compensation is offered untill\n the 80% or 960000 goal is reached."); // Display reason for no incentive
System.out.println("Therefore the Salesman's Total Annual Compensation of\n " + currency.format(totalCompensation) + " is without any additional incentives."); // Display total compensation
}
// Display Compensation above 80% of sales goal
else if (annualSales >= startCompensation)
{
commission80 = annualSales * above80 ; // Total of annualSales above 80%
totalCompensation80 = commission80 + baseSalary ; // Total commission
// Display Commision
System.out.println(" Annual Sales Amount of = " + currency.format(annualSales) ); // Display sales amount
System.out.println(" Multiplied by = " + above80 + "%"); // Display percent
System.out.println(" Gives a Total Commission of = " + currency.format(commission80) ); // Display commision
System.out.println("Total Commission Added to Base Salary of = " + currency.format(baseSalary) ); // Display base salary
System.out.println("\n Gives the Salesman's\n Total Annual Compensation of = " + currency.format(totalCompensation80) ); // Display total compensation
}
// Display Compensation above 100% of sales goal
else if (annualSales >= additionalCompensation)
{
commission100 = annualSales * above100 ; // Total of annualSales above 80%
totalCompensation100 = commission100 + baseSalary ; // Total commission
// Display Commision
System.out.println(" Annual Sales Amount of = " + currency.format(annualSales) ); // Display sales amount
System.out.println(" Multiplied by = " + above100 + "%"); // Display percent
System.out.println(" Gives a Total Commission of = " + currency.format(commission100) ); // Display commision
System.out.println("Total Commission Added to Base Salary of = " + currency.format(baseSalary) ); // Display base salary
System.out.println("\n Gives the Salesman's\n Total Annual Compensation of = " + currency.format(totalCompensation100) ); // Display total compensation
} // End if-else-if Statement
} // End Main method
} // End class Multiply