package cheggjan20public class BasePlusCommissionEmployee int employeeID String Essay
Share: Twitter, Facebook, Pinterest
Free Essay
Nov 26th, 2019

package cheggjan20public class BasePlusCommissionEmployee int employeeID String Essay

package cheggjan20;public class BasePlusCommissionEmployee { int employeeID; String firstName; String lastName; double baseSalary; int grossSales; double commisionRate; //parameterised constructors BasePlusCommissionEmployee(int employeeID,String firstName,String lastName) { if(employeeID>0) {this.employeeID=employeeID;} if(firstName!=null) {this.firstName=firstName;} if(lastName!=null) {this.lastName=lastName;} } BasePlusCommissionEmployee(int employeeID,String firstName,String lastName,double baseSalary,int grossSales,double commisionRate) { if(employeeID>0) {this.employeeID=employeeID;} if(firstName!=null) {this.firstName=firstName;} if(lastName!=null) {this.lastName=lastName;} if(commisionRate>=0.1 && commisionRate0) { this.baseSalary = baseSalary; } else this.

baseSalary=200.00; if(grossSales!=0) this.grossSales = grossSales; } //getters and setters public int getEmployeeID() { return employeeID; } public int getGrossSales() { return grossSales; } public void setGrossSales(int grossSales) { if(grossSales!=0) this.grossSales = grossSales; } public double getCommisionRate() { return commisionRate; } public void setCommisionRate(int commisionRate) { if(commisionRate>=0.1 && commisionRate0) { this.employeeID = employeeID; }} public void setFirstName(String firstName) { if(firstName!=null) { this.firstName = firstName; } } public void setLastName(String lastName) { if(lastName!=null) { this.lastName = lastName; } } public void setBaseSalary(double baseSalary) { if(baseSalary>0) { this.baseSalary = baseSalary; } else this.baseSalary=200.00; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public double getBaseSalary() { return baseSalary; } public double earnings()//to calculate earnings { return commisionRate*grossSales+baseSalary; } public String toString()//to print details { return “nEmployee Id : “+employeeID+”nFirst Name: “+firstName+”nLast Name : “+lastName+”nBase Salary : $”+baseSalary+”nGross Sales : $”+grossSales+”nCommision Rate : “+commisionRate+”%”; } }BasePlusCommissionEmployeeTest.javapackage cheggjan20;public class BasePlusCommissionEmployeeTest { public static void main(String[] args) { // TODO Auto-generated method stub //creating objects BasePlusCommissionEmployee e1=new BasePlusCommissionEmployee(121,”Nick”,”Jonas”,30000,300,20); BasePlusCommissionEmployee e2=new BasePlusCommissionEmployee(123,”Priyanka”,”Jonas”,40000,400,20); //displaying details System.out.println(e1); System.out.println(“Total Commision : $”+e1.earnings()); System.out.println(e2); System.out.println(“Total Commision : $”+e2.earnings()); }}Output is :Employee Id : 121First Name: NickLast Name : JonasBase Salary : $30000.0Gross Sales : $300Commision Rate : 0.1%Total Commision :30030.0Employee Id : 123First Name: PriyankaLast Name : JonasBase Salary : $40000.0Gross Sales : $400Commision Rate : 0.1%Total Commision :40040.0CheckingAccount.javapackage cheggjan20;public class CheckingAccount { int accountNumber; String customerName; double accountBalance; //parameterised constructor CheckingAccount(int ac,String cname,double balance) { accountNumber=ac; customerName=cname; accountBalance=balance; } //getters and setters public int getAccountNumber() { return accountNumber; } public String getCustomerName() { return customerName; } public double getAccountBalance() { return accountBalance; } public void setAccountBalance(double accountBalance) { if(accountBalance>50.00)//it should always be greater than that this.accountBalance = accountBalance; } public double withdraw (double amount)//to withdraw ammount and return balance { if((accountBalance-amount-2)>=50.00) accountBalance=accountBalance-amount-2; return accountBalance; } public String toString()//to display details { return “Account Number : “+accountNumber+”nCustomer Name : “+customerName+”nAccount Balance : $”+accountBalance; } }CheckingAccountTest.javapackage cheggjan20;public class CheckingAccountTest { public static void main(String args[]) {//creating objects CheckingAccount c1=new CheckingAccount(121,”Nick”,600.00); CheckingAccount c2=new CheckingAccount(122,”Nickos”,700.00); //displaying details System.out.println(c1); System.out.println(“Balance after withdrawl of $200 is : $”+c1.withdraw(200)); System.out.println(c2); System.out.println(“Balance after withdrawl of $400 is : $”+c2.withdraw(400)); }}

Don't use plagiarized sources. Get Your Custom Essay on
package cheggjan20public class BasePlusCommissionEmployee int employeeID String Essay
Just from $13/Page
Order Essay

Recommended stories

Public administration

(SPY) Suicide Prevention within our Youth is an organization working to prevent our youth from committing suicide giving them hope, […]