I find loop statements really hard so I need help. This program lets the user input each salesperson's gross sale, calculates their commission which is $200 plus 9% of their sale, and displays the salesperson's earning. Also, to sum up all of the total sales inputted, the user should input -1, hence ending the program. This program uses a while loop and the output should be like this:
ENTER SALES IN DOLLAR (-1 TO END): 5000.00
SALARY: $ 650.00
ENTER SALES IN DOLLAR (-1 TO END): 6000.00
SALARY: $ 740.00
ENTER SALES IN DOLLAR (-1 TO END): 7000.00
SALARY: $ 830.00
ENTER SALES IN DOLLAR (-1 TO END): -1
THE TOTAL SALARY FOR THE WEEK: $2200.00
GOOD DAY! THANK YOU FOR USING THE SYSTEM!
and so far here's the code I have:
public static void main(String[] args)
{
Scanner scan = new Scanner (System.in);
double sales = 0, salary = 0, totalSalary;
while (sales >= 1)
{
System.out.print("ENTER SALES IN DOLLAR (-1 TO END): ");
sales = scan.nextDouble();
salary = (sales + 200)* 0.09;
System.out.println("SALARY: $ " +salary);
}
}
}
I'm really stuck on where should I put the "while" and how would I stop the loop with "-1"