This assignment is an introduction to the agony and ecstasy of Java programming. It is worth ten percent of your CP2003 grade.
You should create a new directory named as assign2_2003 or any name you like. This directory will contains all the java programs for assignment 2 and related subdirectories for the package required in the assignment two.
When you are done and certain that everything is working correctly, turnin in the assignment as follows.
You will have a file named as assign2.tar
Your tared file assign2.tar is encoded and is sent to my Email address.
The assignment will be marked for good programming style (indentation and appropriate comments), as well as clean compilation (it should work!). Important: Please comment all code, with appropriate comments. The first line is your file name and second line is your name, etc. Upto thirty percent of your mark will be for style.
Let us use abstract methods and polymorphism to perform payroll calculations based on the type of an employee. We use an abstract superclass Employee. The subclasses of Employee are:
Date is an auxiliary class and will be used by Employee . Edit Date.java to implement this class. The Date class contains pertinent information about a Date. For this program, the pertinent information is the day, month and year. The program should check the validation of the date, eg. month shouldn't greater than 13, etc.
You are to write the following methods.
Edit Employee.java to use class date.
class Employee contains attributes:
firstName; //String class
secondName;
static int count; // To count the no. of Employees
Date birthDate;
I'd like you to write the following methods.
Employee( firtName, lastName, birthDay )---constructor !
The constractor should also
count the number of employees created in the application program.
These three classes are subclasses of Employee.
I'd like you to write the following methods.
weeklySalary = basicSalary + commissionPercent * quantity
weeklySalary = wagePerHour* HoursWorked + overHours* 2*wagePerHour
I've done part of the assignment for you.
.... import packages here;
class EmployeeTest {
public static void main(String args[]) throws IOException
{
BufferedReader input = new BufferedReader(new
InputStreamReader(System.in));
/*Create an object input to read from keyboard */
....Declarations of variables here;
....Create Employee objects here;
....a prompt message to user which type of employee's name are required
to input from keyboard
try{
for (int num=1; num<=3; num ++){ // you may not use this loop
... a prompt message for input a name
... =input.readLine(); //read a line of characters
/* Right part of assignment is a String variable of fristName or secondName */
System .out.flush();
//forces any buffered output bytes to be written out.
... a prompt message for input a name
... = input.readLine();
.... birthday input
... long aDate =Long.parseLong(A string read from Keyboard );
.....
... assign names to Employees;
... and print out the Employees information by calling method
from class Employee
catch {IOException e) {...}
}
Here is
the site for all the methods defined by Java. You should check the
definitions of the methods you will use.
Good luck!