// Example 2 of OOP -
add a method in the class
public class oop2
{
public static void main(String[] args)
{
Employee E1 = new Employee();
Employee E2 = new Employee();
E1.Name = "Kirk";
E1.HourlyWage = 25;
E1.HoursWorked = 40;
E2.Name = "Liliana";
E2.HourlyWage = 18;
E2.HoursWorked = 30;
System.out.println(E1.Name + " earned $" +
E1.GetPayCheck());
System.out.println(E2.Name + " earned $" +
E2.GetPayCheck());
}
}
class Employee
{
String Name;
double HourlyWage, HoursWorked;
double GetPayCheck()
{
return HourlyWage * HoursWorked;
}
}