A large company pays its salespeople on a commission basis. The salespeople each
ID: 3665886 • Letter: A
Question
A large company pays its salespeople on a commission basis. The salespeople each receive $200 per week plus 9% of their gross sales for that week. For example a salesperson who sells $5000 worth of chemicals in a week receives $200 plus 9% of $5000, or total of $650. Develop a Java application that inputs one salesperson's items sold for last week and calculates and displays that salesperson's earnings. There's no limit to eh number of items that can be sold.
//This is what I have, I am not sure if I answered this correctly. Can someone look over this and help me? Are my variables named correctly, my professor is a real stickler about them. Thanks.
import java.util.Scanner;
public class Sales
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
double gross = (0.0);
int product = (0);
double earnings = gross;
int number = product;
while (product < 4)
{
product++;
System.out.println("Enter number sold of product #" + product + ":");
number = input.nextInt();
if (product == 1)
gross = gross + number * 239.99;
else if (product == 2)
gross = gross + number * 129.75;
else if (product == 3)
gross = gross + number * 99.95;
else if (product == 4)
gross = gross + number * 350.89;
}
earnings = 0.09 * gross + 200;
String result = ("Earnings this week: $" + earnings);
System.out.println(result);
}
}
Explanation / Answer
your while statement should have <=4 instead of <4 if u are writting
else if (product == 4)
gross = gross + number * 350.89;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.