All pastes #745728 Raw Copy code Copy link Edit

Exercise 3.10

public java v1 · immutable
#745728 ·published 2007-10-22 17:13 UTC
rendered paste body
public class Employee{	private double monthlySalary=0.0f;	private String firstName="someone",lastName="someone";	public Employee(String firstName,String lastName,Double monthlySalary)	{		this.firstName=firstName;		this.lastName=lastName;		this.monthlySalary=monthlySalary;	}	public double getmonthlySalary()	{		if (monthlySalary<0)		{			return 0.0f;		}		else		{			return monthlySalary;		}	}	public String getlastName()	{		return lastName;	}	public String getfirstName()	{		return firstName;	}}/* Another class*/public class EmployeeTest{	public static void main(String argv[])	{		Employee Justin=new Employee("Chan","Siu Ming",8000.0);		Employee Hoyin=new Employee("Chan","Tai Ming",10000.0);		System.out.printf("Justin yearly salary is $%.1f.\n" , (Justin.getmonthlySalary()*12));		System.out.printf("Hoyin yearly salary is $%.1f.\n" , (Hoyin.getmonthlySalary()*12));		System.out.println("After 10% raise!!");		System.out.printf("Justin yearly salary is $%.1f.\n" , (Justin.getmonthlySalary()*12*1.1));		System.out.printf("Hoyin yearly salary is $%.1f.\n" ,(Hoyin.getmonthlySalary()*12*1.1));	}}