title: Calculating employee's salary using class and object
body: <p>I have to write a program to calculate the employees' salary using getter and setter. I have a problem regarding how to display the calculated salary of the employees. It doesn't show the salary.</p>
  <p>Here is what I've done so far:</p>
  <p>employee.java</p>
  <pre class="lang-java prettyprint-override"><code>public class employee {
  
      private String firstName,lastName;
      private int hours;
      private double wage,salary;
  
      public String getFirstName() {
          return firstName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
  
      public int getHours() {
          return hours;
      }
  
      public void setHours(int hours) {
          this.hours = hours;
      }
  
      public double getWage() {
          return wage;
      }
  
      public void setWage(double wage) {
          this.wage = wage;
      }
  
      public double getSalary() {
          salary = getWage()* getHours();
          return salary;
      }
  
      public void setSalary(double salary) {
  
          this.salary = salary;
      }}
  </code></pre>
  <p>main.java</p>
  <pre class="lang-java prettyprint-override"><code>    public static void main(String[] args) {
  
          Scanner input = new Scanner(System.in);
  
          System.out.println(&quot;Enter the number of employees : &quot;);
          int n = input.nextInt();
  
          employee[] emp = new employee[n];
  
          for (int i = 0; i &lt; emp.length; i++) {
              emp[i] = new employee();
  
              System.out.println(&quot;enter employee&quot; + (i + 1) + &quot; first name : &quot;);
              emp[i].setFirstName(input.next());
  
              System.out.println(&quot;enter employee&quot; + (i + 1) + &quot; last name : &quot;);
              emp[i].setLastName(input.next());
  
              System.out.println(&quot;enter employee&quot; + (i + 1) + &quot; wage : &quot;);
              emp[i].setWage(input.nextInt());
  
              System.out.println(&quot;enter employee&quot; + (i + 1) + &quot; number of working hours : &quot;);
              emp[i].setHours(input.nextInt());
  
              System.out.println(&quot;salary of employee&quot; + (i + 1) + &quot; is : &quot;);
              emp[i].getSalary();
  
          }
          int index = 0;
          for (employee temp :
                  emp) {
              System.out.println(&quot;employee&quot; + (++index) + &quot;first name&quot; + temp.getFirstName());
              System.out.println(&quot;employee&quot; + (++index) + &quot;last name&quot; + temp.getLastName());
              System.out.println(&quot;employee&quot; + (++index) + &quot;wage&quot; + temp.getWage());
              System.out.println(&quot;employee&quot; + (++index) + &quot;num of working hours&quot; + temp.getHours());
              System.out.println(&quot;employee&quot; + (++index) + &quot;salary&quot; + temp.getSalary());
  
          }
      }
  </code></pre>