Results 1 to 6 of 6
  1. #1
    dannyh34 is offline Member
    Join Date
    May 2015
    Posts
    3
    Rep Power
    0

    Default I need help with this please!

    COMP 1409 Lab 5-a ( 2 points ) In-class lab
    A local company is a retail seller of personal computers. The sales staff works strictly on commission. At the end of the month each sales person's commission is calculated. Create a class called CommissionSales to calculate the commission for the sales staff.
    Declare these symbolic constants at the top of your class: public static final double RATE_A = 0.05
    public static final double RATE_B = 0.10 public static final double RATE_C = 0.12 public static final double RATE_D = 0.14 public static final double RATE_E= 0.16 public static final int FIRST_LEVEL_SALES = 10000;
    public static final int SECOND_LEVEL_SALES = 15000 public static final int THIRD_LEVEL_SALES = 18000 public static final int FOURTH_LEVEL_SALES = 20000
    Here are the relevant attributes:
    String salesPersonName double salesAmountInCAD
    double salesCommissionRate
    Provide two constructors. Both constructors call mutator methods to initialize the instance variables. The default constructor passes an empty string to the set method for the salesPersonName field and the default value to the salesAmountInCAD set method. See below for details about the mutators.
    The second constructor accepts parameters to initialize instance variables (salesPersonName, salesAmountInCAD) by passing the parameters to the corresponding set method. See below for details about the mutators.
    The mutator method of salesAmountInCAD validates the passed parameter and uses it only if its positive. If negative the instance variable is not changed. The mutator for salesPersonName validates the passed parameter and ensures it is not null. If null, the instance variable is set to an empty string ().
    Provide a mutator method called calculateCommissionRate() that is called from both constructors. This method will assign the appropriate rate to the instance variable salesCommissionRate according to the sales person's sales. The rate is determined
    according to the following table:
    Sales
    Less than 10000 10000 to 14999 15000 to 17999 18000 to 21999 22000 or more
    Percentage rate
    5% A 10% B 12% C 14% D 16% E
    Provide a method called calculatePay() which calculates and returns the sales person's pay based on the amount of sales at the commission rate, for example a sales person with $16000 in sales earns 12% commission of his or her sales which is $1920.
    Provide standard accessor methods for all fields.
    Provide a method called displayDetails() . This method displays sales person's name, rate and pay on the screen.
    Demonstrate your completed project to your instructor or TA before leaving the lab and be sure we have checked it off. A suggested solution will be given during the next class and labs that have not been checked off will not receive any points.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: I need help with this please!

    Ok, you dumped your entire homework here; now what? You should at least show what you have done yourself and which parts you don't understand. Dumping a (large) piece of text here just shows that you even didn't attempt to do anything yourself.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    dannyh34 is offline Member
    Join Date
    May 2015
    Posts
    3
    Rep Power
    0

    Default Re: I need help with this please!

    Hey I did some of it myself will add it now.

  4. #4
    dannyh34 is offline Member
    Join Date
    May 2015
    Posts
    3
    Rep Power
    0

    Default Re: I need help with this please!

    Java Code:
    /**
     * Write a description of class CommissionSales here.
     * 
     * @author (Danny Hamilton) 
     * @version (27-05-2015)
     */
    public class CommissionSales
    {
        public static final double RATE_A = 0.05;
        public static final double RATE_B = 0.10;
        public static final double RATE_C = 0.12;
        public static final double RATE_D = 0.14;
        public static final double RATE_E= 0.16;
        public static final int FIRST_LEVEL_SALES = 10000;
        public static final int SECOND_LEVEL_SALES = 15000;
        public static final int THIRD_LEVEL_SALES = 18000;
        public static final int FOURTH_LEVEL_SALES = 20000;
    
        private String salesPersonName; 
        private double salesAmountInCAD;
        private double salesCommissionRate;
    
        /**
         * CommissionSales Default Constructor
         */
        public CommissionSales(){
            //salesPersonName = "";
            setSalesPersonName  ("");
            setSalesAmountInCAD (0.0);
            setSalesCommission (0.0);
        }
    
        /**
         *Non-Default Constructor 
         * @param newSalesPersonName  parameter to set sPersonName
         * @param newSalesAmountInCAD parameter to set  sAmountInCAD
         * @param newSalesCommissonRate parameter to set sCommissonRate
         */
        public CommissionSales (String newSalesPersonName, double newSalesAmountInCAD, double newSalesCommissonRate)
        {   setSalesPersonName(newSalesPersonName);
            setSalesAmountInCAD(newSalesAmountInCAD);
            setSalesCommissonRate(newSalesCommissonRate);
        }
    
        /**
         * Method getSalesPersonName
         * 
         * @return The return value
         */
        public String getSalesPersonName() {
            return salesPersonName;
        }
    
        /**
         * @return The salesAmount
         */
        public double getSalesAmountInCAD() {
            return salesAmountInCAD;
        }
    
        /**
         * @return The salesCommissonRate
         */
        public double getnewSalesCommissonRate() {
            return salesCommissonRate;
        }
    
        /**
         *@param newSalesPersonName to set the SalesPersonName
         */
        public void setSalesPersonName (String newSalesPersonName){
            if(newSalesPersonName = !null){
                salesPersonName = newSalesPersonName;
            } else { //if( salesPersonName ==null)
                salesPersonName ="";
            }
        }
    
        /**
         *@param newSalesAmount to set the salesAmountInCAD
         */
        public void setSalesAmountInCAD (double newSalesAmountInCAD){
            if(newSalesAmount > 0){ 
                salesAmountInCAD = newSalesAmountInCAD;
            }
        }
    
        /**
         *@param newSalesCommissonRate to set the salesCommissonRate
         */
        public void setSalesCommissonRate( double newSalesCommissonRate){
            if(newSalesCommissonRate > 0){
                salesCommissonRate = newSalesCommissonRate;
            }
        }
    
        /**
         *Method calculatePay to calcuate the pay
         *@return The  pay value
         */
        public double calculatePay(){
            double commisson = COMMISSON_SALES;
            if(salesAmount < FIRST_LEVEL_SALES){
                sales = sales + FIRST_LEVEL_SALES;
            }
    Last edited by JosAH; 05-27-2015 at 08:12 AM. Reason: added [code] ... [/code] tags

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: I need help with this please!

    Ok, you did the constructors and the getters and setters but you didn't tell us about the part you don't understand; we're not allowed to carry crystal balls here, so you have to be more explicit.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: I need help with this please!

    Quote Originally Posted by dannyh34 View Post
    I need help with this please!
    Please go through the Forum Rules, particularly the third paragraph.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •