Question

This Java program must use classes and object-oriented design (OOD) as I'm in a more advanced...

This Java program must use classes and object-oriented design (OOD) as I'm in a more advanced Java class.

(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.

IMPORTANT NOTE!!: As stated above, this program must use classes and object-oriented design (OOD). Also, please add detailed, but brief comments to most, if not all of the code to explain what is being used in the code and what is does so I have a better understanding of the code. For example:

// Condition to check the price is less than zero or not.

if (price < 0)

Thank you! :)

Here's what I have so far:

import javax.swing.JOptionPane;
public class SalesCommissionCalculator
{
public static void main( String args[] )
{
//Declaring the required variables.
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 + ":" );
// Converts numbers from type String to type int.
number = Integer.parseInt( input );
//Calculating the sales.
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;
//Printing the result.
String result = "Weekly Earnings: " + earnings;
JOptionPane.showMessageDialog(null, result, "Sales",JOptionPane.INFORMATION_MESSAGE );
}
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program created using classes and OOD concepts:

SalesPerson.java

public class SalesPerson{

private double firstItemSale, secondItemSale, thirdItemSale, fourthItemSale;

public double getFirstItemSale() {

return firstItemSale;

}

public void setFirstItemSale(double firstItemSale) {

this.firstItemSale = firstItemSale;

}

public double getSecondItemSale() {

return secondItemSale;

}

public void setSecondItemSale(double secondItemSale) {

this.secondItemSale = secondItemSale;

}

public double getThirdItemSale() {

return thirdItemSale;

}

public void setThirdItemSale(double thirdItemSale) {

this.thirdItemSale = thirdItemSale;

}

public double getFourthItemSale() {

return fourthItemSale;

}

public void setFourthItemSale(double fourthItemSale) {

this.fourthItemSale = fourthItemSale;

}

public double getTotalCommission(){

return (firstItemSale + secondItemSale + thirdItemSale + fourthItemSale) * 0.09;

}

}

SalesCommissionCalculator.java

import javax.swing.JOptionPane;

public class SalesCommissionCalculator

{

public static void main( String args[] )

{

//Declaring the required variables.

double gross = 0.0, earnings;

int product = 0, number;

String input;

SalesPerson sp = new SalesPerson();

while ( product < 4 )

{

product++;

// Read number from user as a string.

input =JOptionPane.showInputDialog("Enter number sold of product #" + product + ":" );

// Converts numbers from type String to type int.

number = Integer.parseInt( input );

//Calculating the sales.

if ( product == 1 )

sp.setFirstItemSale(number * 239.99);

else if ( product == 2 )

sp.setSecondItemSale(number * 129.75);

else if ( product == 3 )

sp.setThirdItemSale(number * 99.95);

else if ( product == 4 )

sp.setFourthItemSale(number * 350.89);

}

earnings = sp.getTotalCommission() + 200;

//Printing the result.

String result = "Weekly Earnings: " + earnings;

JOptionPane.showMessageDialog(null, result, "Sales",JOptionPane.INFORMATION_MESSAGE );

}

}

**Comment for any further queries.

Add a comment
Know the answer?
Add Answer to:
This Java program must use classes and object-oriented design (OOD) as I'm in a more advanced...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A large company pays its salespeople on a commission basis. The salespeople each receive $200 per...

    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 reeives $200 plus 9% of $5000, or a total of $650. You have been supplied with a list of 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...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

  • Java I - Write a program that will use static methods as described in the specifications below. U...

    Java I - Write a program that will use static methods as described in the specifications below. Utilizing the if and else statements, write a program which will calculate a commission based on a two-tiered commission plan of 2% and 5% paid on amounts of $10,000 or less, or over $10,000 in monthly sales by a sales force paid on a commission basis. Use the output specifications below. --- (Please make detailed comments so I can better understand the code....

  • Please use the JAVA code attached as an input to the program that must be created...

    Please use the JAVA code attached as an input to the program that must be created IN JAVA. Instructions of the program: java code: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * */ import java.util.Random; public class Rand_Z3_Exp { /** * @param args the command line arguments */ public static void main(String[] args) {...

  • Please use the JAVA code attached as an input to the program that must be created IN JAVA. Instru...

    Please use the JAVA code attached as an input to the program that must be created IN JAVA. Instructions of the program: java code: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * */ import java.util.Random; public class Rand_Z3_Exp { /** * @param args the command line arguments */ public static void main(String[] args) {...

  • Required: 1. What is the amount of Apple’s accounts receivable as of September 30, 2017? 2....

    Required: 1. What is the amount of Apple’s accounts receivable as of September 30, 2017? 2. Compute Apple’s accounts receivable turnover as of September 30, 2017. 3. How long does it take, on average, for the company to collect receivables for fiscal year ended September 30, 2017? 4. Apple’s most liquid assets include (a) cash and cash equivalents, (b) short-term marketable securities, (c) accounts receivable, and (d) inventory. Compute the percentage that these liquid assets (in total) make up of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT