Computer Science, asked by droptovai, 9 months ago

Create a class SalaryCalculation that is describe as below: Class Name : SalaryCalculation Data members : name(String type data) basicPay, specialAlw, conveyanceAlw, gross, pf, netSalary, AnnualSal (all double type data) Member methods: SalaryCalculation() - A constructor to assign name of employee (name), basic salary (basicPay) of your choice and conveyance allowance (conveyanceAlw) as Rs. 1000.00 void SalaryCal() - to calculate other allowance and salaries as given: specialAlw = 25% of basic salary. netSalary = gross – pf AnnualSal = 12 months netSalary. void display() - to print the name and other calculations with suitable headings. Write a program in java to calculate all the details mentioned above and print them all.

Answers

Answered by dreamrob
0

import java.util.*;

import java.lang.*;

import java.io.*;

class SalaryCalculation

{

   String name;

   double basicPay, specialAlw, conveyanceAlw, gross, pf, netSalary, AnnualSal;

   SalaryCalculation()

   {

       name = "Nikita Mishra";

       basicPay = 150000.00;

       conveyanceAlw = 1000.00;

   }

   void SalaryCal()

   {

       specialAlw = basicPay*(25.0/100.0);

       pf = basicPay*(12.0/100.0);

       gross = 150000.00 + specialAlw + conveyanceAlw;

       netSalary = gross - pf;

       AnnualSal = 12 * netSalary;

   }

   void display()

   {

       System.out.println("Name of Employee : " + name);

       System.out.println("Basic Pay : " + basicPay);

       System.out.println("Special Allowance : " + specialAlw);

       System.out.println("Conveyance Allowance : " + conveyanceAlw);

       System.out.println("Gross : " + gross);

       System.out.println("PF : " + pf);

       System.out.println("Net Salary : " + netSalary);

       System.out.println("Annual Salary : " + AnnualSal);

   }

public static void main (String[] args) throws java.lang.Exception

{

    Scanner Sc = new Scanner(System.in);

    SalaryCalculation sal = new SalaryCalculation();

    sal.SalaryCal();

    sal.display();

}

}

Similar questions