Answer to Question #264719 in Java | JSP | JSF for LYNN

Question #264719

Martin your friend has declared a class called Employee with the following members; Employee ID, Employee Name, Basic Salary, Allowance, and Net Salary. a) Write a code for a member function called get_input that will be used for data input. (3 Marks) b) Write a code for a member function called Calculate that will be used to calculate net salary as the sum of basic salary and allowances. (2 Marks) c) Write a code for the default constructor that will assign values to the variables in the Employee class. (3 Marks) d) Write a code for the default constructor. (3 Marks) e) Write a complete program that captures and includes all the details in (a-d) above. Run the code and show your output. 


1
Expert's answer
2021-11-12T00:06:42-0500
import java.util.Scanner;

class Employee {
  private String emoployeeName;
  private int basicSalary;
  private int allowance;
  private int netSalary;
  
  public Employee() {}

  public Employee(String a, int b, int c, int d){
    employeeName = a;
    basicSalary = b;
    allowance = c;
    netSalary = d;
  }  

  public void calculate() {
    allowance = basicSalary + newSalary;
  }
  
  public void getInput() {
    Scanner s = new Scanner(System.in);
    basicSalary = s.nextInt();
    netSalary = s.nextInt();
  }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS