Я не знаю, что в этом плохого, я новичок.
Код: Выделить всё
public class t7Employee {
private double salary;
private String name;
private double insuranceRate;
private double taxRate;
private double NetSalary;
private double deductions;
t7Employee(double salary, String name){
this.salary = salary;
this.name = name;
}
public void netSalary(){
insuranceRate = 1/100 * salary;
taxRate = 1/10 * salary;
deductions = insuranceRate + taxRate;
NetSalary = salary - (deductions);
}
public void displaySalaryInfo(){
System.out.println(name+"'s gross salary :"+salary
+"\nnet salary: "+NetSalary+"\namount of deductions: "+deductions);
}
}
class testEmployee
{
public static void main(String[] args) {
t7Employee employee1 = new t7Employee(5000, "John");
employee1.netSalary();
employee1.displaySalaryInfo();
}
}
Оклад Джона брутто: 5000,0
Чистая зарплата: 5000,0
сумма вычета: 0,0
Налог и страховая ставка не рассчитываются.
Подробнее здесь: https://stackoverflow.com/questions/786 ... -insurance