In JAVA: Modify the Firm example from this chapter such that it accomploshes its
ID: 3678492 • Letter: I
Question
In JAVA: Modify the Firm example from this chapter such that it accomploshes its polymorphism using an interface called Payable. The Firm example is below:
//********************************************************************
// Firm.java Author: Lewis/Loftus
//
// Demonstrates polymorphism via inheritance.
//********************************************************************
public class Firm
{
//-----------------------------------------------------------------
// Creates a staff of employees for a firm and pays them.
//-----------------------------------------------------------------
public static void main (String[] args)
{
Staff personnel = new Staff();
personnel.payday();
}
}
Explanation / Answer
This the actual code of my lab program to calculate the pay role of short term emp and long term emp... hoping that this code will helps you . You can modify the way you want.
System.out.println("Salary: "+salary);
System.out.println("Designation: "+des);
}
}
class partTimeEmployees extends Firm
{
int workinghrs, rate;
partTimeEmployees()
{
System.out.println("Enter Number of Working Hours:");
workinghrs = get.nextInt();
}
void calculatepay()
{
rate = 8 * workinghrs;
}
void display()
{
System.out.println("=============================="+" "+"Part Time Employee Details"+" "+"=============================="+" ");
super.display();
System.out.println("Number of Working Hours: "+workinghrs);
System.out.println("Salary for "+workinghrs+" working hours is: $"+rate);
}
}
class Employees
{
public static void main(String args[])
{
System.out.println("================================"+" "+"Enter Full Time Employee Details"+" "+"================================"+" ");
fullTimeEmployees ob1 = new fullTimeEmployees();
partTimeEmployees ob = new partTimeEmployees();
System.out.println("================================"+" "+"Enter Part Time Employee Details"+" "+"================================"+" ");
ob1.display();
ob.calculatepay();
ob.display();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.