Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4.19 (Sales Commission Calculator) A large company pays its salespeople on a com

ID: 3640600 • Letter: 4

Question

4.19 (Sales Commission Calculator)
A large company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of merchandise in a week receives $200 plus 9% of $5000, or a total of $650. You’ve been supplied with a list of the items sold by each salesperson. The values of these items are as follows:
Item Value
1 239.99
2 129.75
3 99.95
4 350.89

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 the number of items that can be sold.

Explanation / Answer

PS: Please rate the answer import javax.swing.JOptionPane; public class Sales { public static void main( String args[] ) { double gross = 0.0, earnings; int product = 0, number; String input; while ( product < 4 ) { product++; // read number from user as a string input = JOptionPane.showInputDialog( "Enter number sold of product #" + product + ":" ); // convert numbers from type String to type int number = Integer.parseInt( input ); 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; JOptionPane.showMessageDialog( null, result, "Sales", JOptionPane.INFORMATION_MESSAGE ); System.exit( 0 ); } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote