gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
Write a class emplyee which displays employee’s name, id, gross salary and next salary…
- User
Write a class emplyee which displays employee’s name, id, gross salary and next salary tax is 5% of the gross salary. net salary =gross salary-tax in java
- Assistant
Here is the implementation for the Employee class in Java:
javapublic class Employee { private String name; private int id; private double grossSalary; public Employee(String name, int id, double grossSalary) { this.name = name; this.id = id; this.grossSalary = grossSalary; } public void displayDetails() { System.out.println("Name: " + name); System.out.println("ID: " + id); System.out.println("Gross Salary: $" + grossSalary); double tax = grossSalary * 0.05; double netSalary = grossSalary - tax; System.out.println("Tax: $" + tax); System.out.println("Net Salary: $" + netSalary); } }