title: JAVA Get & Set methods with calculations
body: <p>new to Java and trying to set up get and set methods. Although one I need to do as calculation based off getSalary() multiplied by getMonths() to get a Year to Date total. </p>
  
  <p>I haven't been able to find out if calculations are possible in get or set methods or I may just be such a newbie I have it in the wrong place. </p>
  
  <pre><code>public class Employee_v2
  {
      //Instance variables
      private String first_name;
      private String last_name;
      private double salary;
      private int months;
      final double increase= 0.25;
      private double year_to_date;
  
      public Employee_v2()
      {
      //fill in the code to set default values to the instance variables
          first_name="";
          last_name="";
          salary= 0.0;
          months= 0; 
      }
  
      //Constructor initializing instance variables with arguments
      public Employee_v2(String f, String l, Double sal, int mo)
      {
          first_name = f;
          last_name = l;
          salary = sal;
          months = mo;  
      }
  
  //set arguments     
      public void setFirst(String f)
      {
          first_name = f;
      }   
      public void setLast (String l)
      {
          last_name = l;
      }   
      public void setSalary (double sal)
      {
          salary = sal;
      }  
      public void setMonths (int mo)
      {
          months = mo;
      } 
      public void setYtdSalary ()
      {
          double yearToDateSal;
          yearToDateSal = getSalary() * getMonths();
      }
  
  
  //get arguments 
      public String getFirst()
      {
          return first_name;
      }
  
     public String getLast()
      {
          return last_name;
      }
  
     public double getSalary()
      {
          return salary;
      }
  
     public int getMonths()
     {
          return months;
     }
  
     public double getYtdSalary()
     {
          return yearToDateSal;     
     }
  
  
  //DISPLAY
  
     public void displayEmployee()
     {
         //display the name and salary of both Employee objects
         System.out.println("Employee first name: "  + getFirst());
         System.out.println("Employee last name: " + getLast());
         System.out.printf("Employee salary: $%.2f\n", getSalary());
  
         //complete the code
         System.out.println("-------------------------------");
  
         //Determine the year to date salary for both employee
         System.out.printf(getFirst() + "'s salary:  $%.2f\n", getSalary());
  
         // System.out.println(jas.getSalary());
         System.out.printf("Year to date salary: $%.2f\n", getYtdSalary());
  
         //set and display salary with increase
         setSalary(getSalary()+ getSalary()*increase);
         System.out.printf("New Salary: $%.2f\n", getSalary());
  
         System.out.println();
         System.out.println();
     }//end method
  }//end Class
  </code></pre>