I am attempting to determine based off of input from the user which formula to calculate. It works when they are both closed off with {} but when the entire statement is closed then my System.out.print does not recognize them. Currently there are no brackets around the if statement. and it is stating that totalSalary is already defined in the main string. Thank you for your time and input.
if(annualSales >= 96000)
{
double totalSalary = annualPay + advCommission;
if(annualSales <= 95999)
{
double totalSalary = annualPay + commission;
//prints table for display
//Columns
System.out.print("SalesPerson\t");
System.out.print("AnnualSales\t");
System.out.print("Commission\t ");
//Columns
System.out.print("Total Salary\t");System.out.println("Difference from user");
//user input
System.out.print(firstName);System.out.print("\t\t");
System.out.println(annualSales); System.out.print(commission);
System.out.print(totalSalary);System.out.println("Difference from user");
//preset 1
System.out.print(presetSalesPerson[0]);
System.out.print("\t\t");
System.out.println(presetAnnualSales[0]); System.out.print("Commission\t ");
System.out.print(totalSalary);System.out.println("Difference from user");
//preset 2
System.out.print(presetSalesPerson[1]);System.out.print("\t\t");
System.out.println(presetAnnualSales[1]); System.out.print("Commission\t ");
System.out.print(totalSalary);System.out.println("Difference from user");
Aucun commentaire:
Enregistrer un commentaire