You have just started a sales job in a department store. Your pay consists of a
ID: 3637698 • Letter: Y
Question
You have just started a sales job in a department store. Your pay consists of a base salary and a commission. The base salary is $5000. The scheme shown below is used to determine the commission rate:
Sales Amount Commission Rate
$0.01 - $5000.00 8 percent
$5000.01 - $10,000.01 10 percent
$10000.01 and above 12 percent
Your goal is to earn $30,000.00 a year. Write a program that finds out the minimum amount of sales you have to generate in order ro make $30,000.00 for the year. Here's what I have so far, and I believe the code is correct, there must be something I'm not doing right because my program won't run!! Please help!!
/* Create a Program to calculate the sales amount need to earn enough commissions to increase your base salary from $5000 per year to $30000 per year.*/
package hw.assignment2.sale.amount;
// Use javax.swing.JoptionPane
import javax.swing.JOptionPane;
public class HWAssignment2SaleAmount {
// This is where the Main method begins
public static void main(String[] args) {
// Commisions needed
final double COMMISSIONS_NEEDED = 30000;
// Declare commissions
double commissions = 0;
// Declare salesAmount
double salesAmount = 1;
//start while loop
while (commissions < COMMISSIONS_NEEDED) {
//Calculate commissions
if (salesAmount >= 10001)
// calculate the commissions if sales are less than 10000
commissions = 5000 * 0.08 + 5000 * 0.10 + (salesAmount - 10000) * 0.12;
else if (salesAmount >= 5001)
// Calculate commissions if sales are greater than 5000
commissions = 5000 * 0.08 + (salesAmount - 5000) * 0.10;
else
// calculate the commissions
commissions = salesAmount * 0.08;
// with increasing salesAmount
salesAmount++;
} //end of while loop
// Display the sales amount
String output = "The sales amount" + salesAmount + " is needed to make a commission of $" + COMMISSIONS_NEEDED;
JOptionPane.showMessageDialog(null, outputs, JOptionPane.INFORMATION_MESSAGE); This is where i get an error message: "Cannot find symbol." "Symbol: variable outputs."
System.exit(0);
}// End the Main method
} // End the class
Explanation / Answer
• // FindSalesAmount.java: Find the sales amount to get the • // desired commission.Base salary 5000,earn30000 a yr. • import javax.swing.JOptionPane; • public class FindSalesAmount { • /** Main method */ • public static void main(String[] args) { • // The commission sought • final double COMMISSION_SOUGHT = 25000; • final double INITIAL_SALES_AMOUNT = 0; • double commission = 0; • double salesAmount = INITIAL_SALES_AMOUNT; • • • • • do { // Increase salesAmount by 1 cent salesAmount += 0.01; • // Compute the commission from the current salesAmount; • if (salesAmount >= 10000.01) • commission = • 5000 * 0.08 + 5000 * 0.1 + (salesAmount - 10000) * 0.12; • else if (salesAmount >= 5000.01) • commission = 5000 * 0.08 + (salesAmount - 5000) * 0.10; • else • commission = salesAmount * 0.08; • } while (commissionRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.