-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSalesCommissionCalculator.java
More file actions
37 lines (29 loc) · 1.28 KB
/
SalesCommissionCalculator.java
File metadata and controls
37 lines (29 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//Note: Company salespeople are paid $200/ week.
//Weekly they also receive 9% of gross sales. (0.09 percent).
//$200 plus 9% of gross sales is what the salespeople earn per week.
//Prompt the salesperson to enter the cost of items sold last week. (Gross sale).
//Save the value in a double variable.
//Use indefinite loop to avoid limiting the number of entries.
//Calculate and display that salesperson's total earning for the week.
//Multiply the gross sales with 0.09.
//Add the multiplied result with their weekly $200 earning.
import java.util.Scanner;
public class SalesCommissionCalculator {
public static void main (String[] args) {
Scanner keyboardInput = new Scanner(System.in);
double weeklyPay = 200;
double grossPercent = 0.09;
double itemsSold = 0;
double totalItemsSold = 0;
double grossEarnings = 0;
double totalEarnings = 0;
while (itemsSold != -1) {
System.out.print("Press -1 to quit or Enter the cost of items sold for last week: ");
itemsSold = keyboardInput.nextDouble();
if (itemsSold != -1) totalItemsSold = totalItemsSold + itemsSold;
grossEarnings = totalItemsSold * grossPercent;
totalEarnings = weeklyPay + grossEarnings;
System.out.println("Your total earnings for last week is: " + totalEarnings);
}
}
}