Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Exercise 3.10
Monday, October 22nd, 2007 at 11:13:23am MDT 

  1. public class Employee
  2. {
  3.         private double monthlySalary=0.0f;
  4.         private String firstName="someone",lastName="someone";
  5.  
  6.         public Employee(String firstName,String lastName,Double monthlySalary)
  7.         {
  8.                 this.firstName=firstName;
  9.                 this.lastName=lastName;
  10.                 this.monthlySalary=monthlySalary;
  11.         }
  12.  
  13.         public double getmonthlySalary()
  14.         {
  15.                 if (monthlySalary<0)
  16.                 {
  17.                         return 0.0f;
  18.                 }
  19.                 else
  20.                 {
  21.                         return monthlySalary;
  22.                 }
  23.         }
  24.  
  25.         public String getlastName()
  26.         {
  27.                 return lastName;
  28.         }
  29.  
  30.         public String getfirstName()
  31.         {
  32.                 return firstName;
  33.         }
  34. }
  35.  
  36. /* Another class*/
  37. public class EmployeeTest
  38. {
  39.         public static void main(String argv[])
  40.         {
  41.                 Employee Justin=new Employee("Chan","Siu Ming",8000.0);
  42.                 Employee Hoyin=new Employee("Chan","Tai Ming",10000.0);
  43.                 System.out.printf("Justin yearly salary is $%.1f.\n" , (Justin.getmonthlySalary()*12));
  44.                 System.out.printf("Hoyin yearly salary is $%.1f.\n" , (Hoyin.getmonthlySalary()*12));
  45.                 System.out.println("After 10% raise!!");
  46.                 System.out.printf("Justin yearly salary is $%.1f.\n" , (Justin.getmonthlySalary()*12*1.1));
  47.                 System.out.printf("Hoyin yearly salary is $%.1f.\n" ,(Hoyin.getmonthlySalary()*12*1.1));
  48.         }
  49.  
  50. }

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
worth-right