Question: Apply the naming conventions for variables, methods, classes, and packages: variable names start with a lowercase character for the first word and uppercase for every
Apply the naming conventions for variables, methods, classes, and packages:
variable names start with a lowercase character for the first word and uppercase for every other word
classes start with an uppercase character of every word
packages use only lowercase characters
methods start with a lowercase character for the first word and uppercase for every other word
Exercise #1: [10 marks]
Write a Java application using eclipse as IDE, that implements the following class(es) as per business requirements mentioned below:
Create a BasePlusCommissionEmployee class (BasePlusCommissionEmployee.java) that has the following instance variables:
Employee ID, first name, last name, base salary, gross sales ( amount in dollars) and commission rate. Define their data types appropriately.
Define only getters for employee ID, first name, last name and base salary. Ensure the proper ( no negative and null values ) data values by implementing data validations.
Define default value of 200.00 dollars for base salary for all the employees.
Lab Assignment #1 _____________Page 1 of 2
Java Programming COMP-228
Define getter and setter for gross sales and commission rate. Ensure their values should never be negative or zero.
Commission rate should be between 0.1 and 1.0%. Set default value 0.1.
Class should have defined two overloaded constructors:
One for initializing all the instance data members (employee ID, first name, last name, gross sales and commission rate)
Second for initializing employee ID, first name, last name only.
Define a public method - double earnings() which calculates employees commission ( commission rate * gross sales + base salary )
Define a public method String toString() which is used to display the objects data
Create a driver class BasePlusCommissionEmployeeTest (BasePlusCommissionEmployeeTest.java) which tests above class by at least creating two objects of the BasePlusCommissionEmployee class.
Exercise #2: [10 marks]
Write a Java application that implements the following class(es) as per business requirements mentioned below:
Create a CheckingAccount class (CheckingAccount.java) that has the following instance variables:
Account number , customer name, account balance
Define only getter for account number and customer name
Define getter and setter for account balance. Balance should be positive and there should be minimum balance of 50.00 dollars all the time.
Class should have defined a constructor:
For initializing all the instance data members
Define one public method public double withdraw (double amount) which is used for taking out money. With every withdrawal, there is transaction fee of 2.00 dollars.
Define a public method String toString() which is used to display the objects data
Create a driver class CheckingAccountTest (CheckingAccountTest.java) which tests above class by at least creating two objects of the CheckingAccount class with different set of data values.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
