JAVA-SE-Tutorial-codeswithpankaj icon indicating copy to clipboard operation
JAVA-SE-Tutorial-codeswithpankaj copied to clipboard

Advanced Level Assignment: Salary System in Java

Open Pankaj-Str opened this issue 1 year ago • 8 comments

Assignment Questions

  1. Class Design:

    • Design an Employee class to store the employee's details:
      • Name
      • ID
      • Basic Salary
      • Designation
      • Department
  2. Salary Components:

    • Add methods to calculate the following components of the salary:
      • House Rent Allowance (HRA) = 20% of Basic Salary
      • Dearness Allowance (DA) = 10% of Basic Salary
      • Provident Fund (PF) = 12% of Basic Salary
      • Medical Allowance = Fixed amount (e.g., 1500)
      • Gross Salary = Basic Salary + HRA + DA + Medical Allowance
      • Net Salary = Gross Salary - PF
  3. Input Handling:

    • Write a method to take input for employee details and basic salary.
    • Ensure the input salary is a positive number.
  4. Output Handling:

    • Write a method to display the employee details and all components of the salary, including Gross Salary and Net Salary.
  5. Validation:

    • Implement input validation to ensure all entered details are valid (e.g., non-empty name, positive salary).
  6. Formatting:

    • Ensure the output is well-formatted and readable.
  7. Main Method:

    • Write the main method to create an Employee object, take input, perform calculations, and display the salary details.

Example Input

Enter your name: Nishant Chouhan
Enter your ID: E123
Enter your Basic Salary: 50000
Enter your Designation: Software Engineer
Enter your Department: IT

Example Output

Employee Salary Details
-----------------------
Name: Nishant Chouhan
ID: E123
Designation: Software Engineer
Department: IT

Basic Salary: 50000.00
House Rent Allowance (HRA): 10000.00
Dearness Allowance (DA): 5000.00
Medical Allowance: 1500.00
Provident Fund (PF): 6000.00

Gross Salary: 66500.00
Net Salary: 60500.00

Assignment Submission

Submit the Java source code file along with a document explaining the implementation, including how the input validation was handled and how the salary components were calculated.

Pankaj-Str avatar Jul 20 '24 13:07 Pankaj-Str

package ifelse;



import java.util.Scanner;

public class salary_system {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String name,id ,mounthselect;
        int  salary, Month, monthDay = 0, year,leaves,Conveyance,Medical,OtherA,Professionalt,PaidD;
        float allowance,leavesAmount,Ysalary,CTC,conveyAmount,medicalAmount,otherAmount,mounthallowance,ProfessionalAmount,mounthnetSalary,TotalDeductions,netsalary;
        mounthselect="";
        System.out.print("Enter the name: ");
        name=sc.next();
        System.out.print("Enter the Employee id: ");
        id=sc.next();

        System.out.print("Enter the Current Year: ");
        year =sc.nextInt() ;
        System.out.print("Enter the Leaves Taken IN this Month: ");
        leaves =sc.nextInt() ;
        System.out.print("Enter the monthly Salary : ");
        salary =sc.nextInt() ;
            System.out.print("Enter the Conveyance Allowance in Percentage: ");
        Conveyance =sc.nextInt() ;
             System.out.print("Enter the Medical Allowance in Percentage: ");
        Medical =sc.nextInt() ;
            System.out.print("Enter the Other Allowances in Percentage: ");
        OtherA =sc.nextInt() ;
            System.out.print("Enter the Professional Tax in Percentage: ");
        Professionalt =sc.nextInt() ;
        System.out.print("Enter the Current Month: ");
        Month =sc.nextInt();
        switch (Month) {
            case 1:
                monthDay = 31;
                mounthselect = "January";
                break;
            case 2:
                if ((year % 400 == 0) || ((year % 100 != 0) && (year % 4 == 0))) {
                    monthDay = 29;
                } else monthDay = 28;
                mounthselect = "February";
                break;
            case 3:
                monthDay = 31;
                mounthselect = "March";
                break;
            case 4:
                monthDay = 30;
                mounthselect = "April";
                break;
            case 5:
                monthDay = 31;
                mounthselect = "May";
                break;
            case 6:
                monthDay = 30;
                mounthselect = "June";
                break;
            case 7:
                monthDay = 31;
                mounthselect = "July";
                break;
            case 8:
                monthDay = 31;
                mounthselect = "August";
                break;
            case 9:
                monthDay = 30;
                mounthselect = "September";
                break;
            case 10:
                monthDay = 31;
                mounthselect = "October";
                break;
            case 11:
                monthDay = 30;
                mounthselect = "November";
                break;
            case 12:
                monthDay = 31;
                mounthselect = "December";
                break;
            default:
                System.out.println("enter Between 1 to 12 ");
        }
                //calculation
            PaidD=monthDay-leaves;
            leavesAmount=(float)(salary/monthDay)*(leaves);
            Ysalary=salary*12;
            conveyAmount=(float) Ysalary*Conveyance/100;
            otherAmount=(float) Ysalary*OtherA/100;
            medicalAmount=(float) Ysalary*Medical/100;
            allowance=conveyAmount+otherAmount+medicalAmount;
            mounthallowance=allowance/12 ;
            CTC=Ysalary+allowance;
            mounthnetSalary=salary-leavesAmount;
            ProfessionalAmount=(float) mounthnetSalary*Professionalt/100;
            TotalDeductions=leavesAmount+ProfessionalAmount;
            netsalary=mounthnetSalary+mounthallowance-TotalDeductions;
        System.out.println();
        System.out.println();
        System.out.println("------Output---------");
        System.out.println();
        System.out.println();

                System.out.println("Employee Name= " +name);
                System.out.println("Employee Id ="+ id);
                System.out.println("Paid Days = "+ PaidD);
                System.out.println("Basic Salary= "+ salary);
                System.out.println("Total Working Days = "+ monthDay);
                System.out.println("Leaves Amount ="+ leavesAmount);
                System.out.println("Conveyance Allowance ="+ conveyAmount);
                System.out.println("Other Allowance ="+ otherAmount);
                System.out.println("Medical Allowance ="+ medicalAmount);
                System.out.println("CTC =" + CTC);
                System.out.println("Total Allowance =" +allowance);
                System.out.println("Professional Tax = " + ProfessionalAmount);
                System.out.println("Total Deductions = "+ TotalDeductions);
                System.out.println("Net Salary = " +netsalary);
                System.out.println("Month = " +mounthselect+"/"+year);







        }
    }

AlokSingh100 avatar Jul 20 '24 13:07 AlokSingh100

package ifelse;



import java.util.Scanner;

public class salary_system {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String name,id ,mounthselect;
        int  salary, Month, monthDay = 0, year,leaves,Conveyance,Medical,OtherA,Professionalt,PaidD;
        float allowance,leavesAmount,Ysalary,CTC,conveyAmount,medicalAmount,otherAmount,mounthallowance,ProfessionalAmount,mounthnetSalary,TotalDeductions,netsalary;
        mounthselect="";
        System.out.print("Enter the name: ");
        name=sc.next();
        System.out.print("Enter the Employee id: ");
        id=sc.next();

        System.out.print("Enter the Current Year: ");
        year =sc.nextInt() ;
        System.out.print("Enter the Leaves Taken IN this Month: ");
        leaves =sc.nextInt() ;
        System.out.print("Enter the monthly Salary : ");
        salary =sc.nextInt() ;
            System.out.print("Enter the Conveyance Allowance in Percentage: ");
        Conveyance =sc.nextInt() ;
             System.out.print("Enter the Medical Allowance in Percentage: ");
        Medical =sc.nextInt() ;
            System.out.print("Enter the Other Allowances in Percentage: ");
        OtherA =sc.nextInt() ;
            System.out.print("Enter the Professional Tax in Percentage: ");
        Professionalt =sc.nextInt() ;
        System.out.print("Enter the Current Month: ");
        Month =sc.nextInt();
        switch (Month) {
            case 1:
                monthDay = 31;
                mounthselect = "January";
                break;
            case 2:
                if ((year % 400 == 0) || ((year % 100 != 0) && (year % 4 == 0))) {
                    monthDay = 29;
                } else monthDay = 28;
                mounthselect = "February";
                break;
            case 3:
                monthDay = 31;
                mounthselect = "March";
                break;
            case 4:
                monthDay = 30;
                mounthselect = "April";
                break;
            case 5:
                monthDay = 31;
                mounthselect = "May";
                break;
            case 6:
                monthDay = 30;
                mounthselect = "June";
                break;
            case 7:
                monthDay = 31;
                mounthselect = "July";
                break;
            case 8:
                monthDay = 31;
                mounthselect = "August";
                break;
            case 9:
                monthDay = 30;
                mounthselect = "September";
                break;
            case 10:
                monthDay = 31;
                mounthselect = "October";
                break;
            case 11:
                monthDay = 30;
                mounthselect = "November";
                break;
            case 12:
                monthDay = 31;
                mounthselect = "December";
                break;
            default:
                System.out.println("enter Between 1 to 12 ");
        }
                //calculation
            PaidD=monthDay-leaves;
            leavesAmount=(float)(salary/monthDay)*(leaves);
            Ysalary=salary*12;
            conveyAmount=(float) Ysalary*Conveyance/100;
            otherAmount=(float) Ysalary*OtherA/100;
            medicalAmount=(float) Ysalary*Medical/100;
            allowance=conveyAmount+otherAmount+medicalAmount;
            mounthallowance=allowance/12 ;
            CTC=Ysalary+allowance;
            mounthnetSalary=salary-leavesAmount;
            ProfessionalAmount=(float) mounthnetSalary*Professionalt/100;
            TotalDeductions=leavesAmount+ProfessionalAmount;
            netsalary=mounthnetSalary+mounthallowance-TotalDeductions;
        System.out.println();
        System.out.println();
        System.out.println("------Output---------");
        System.out.println();
        System.out.println();

                System.out.println("Employee Name= " +name);
                System.out.println("Employee Id ="+ id);
                System.out.println("Paid Days = "+ PaidD);
                System.out.println("Basic Salary= "+ salary);
                System.out.println("Total Working Days = "+ monthDay);
                System.out.println("Leaves Amount ="+ leavesAmount);
                System.out.println("Conveyance Allowance ="+ conveyAmount);
                System.out.println("Other Allowance ="+ otherAmount);
                System.out.println("Medical Allowance ="+ medicalAmount);
                System.out.println("CTC =" + CTC);
                System.out.println("Total Allowance =" +allowance);
                System.out.println("Professional Tax = " + ProfessionalAmount);
                System.out.println("Total Deductions = "+ TotalDeductions);
                System.out.println("Net Salary = " +netsalary);
                System.out.println("Month = " +mounthselect+"/"+year);







        }
    }
Salary Components:

Add methods to calculate the following components of the salary:
House Rent Allowance (HRA) = 20% of Basic Salary
Dearness Allowance (DA) = 10% of Basic Salary
Provident Fund (PF) = 12% of Basic Salary
Medical Allowance = Fixed amount (e.g., 1500)
Gross Salary = Basic Salary + HRA + DA + Medical Allowance
Net Salary = Gross Salary - PF

Pankaj-Str avatar Jul 20 '24 13:07 Pankaj-Str


import java.util.Scanner;

class Employee{
    String name,id,designation,department;
    int basic_salary;
    float house,dearness,provident;

     void employee_detail(){
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter Your Name: ");
        name=sc.nextLine();
        System.out.println("Enter Your ID: ");
        id=sc.nextLine();
        System.out.println("Enter Your Designation: ");
        designation=sc.nextLine();
        System.out.println("Enter Your Department: ");
        department=sc.nextLine();
        System.out.println("Enter your Basic salary: ");
        basic_salary=sc.nextInt();
        System.out.println("Enter House Rent Allowance: ");
        house=sc.nextFloat();
        System.out.println("Enter Dearness Allowance: ");
        dearness=sc.nextFloat();
        System.out.println("Enter Provident Fund: ");
        provident=sc.nextFloat();
    }

    void display(){
        System.out.println("Employee Salary Details");
        System.out.println("........................");
        System.out.println("Name: "+name);
        System.out.println("ID: "+id);
        System.out.println("Designation: "+designation);
        System.out.println("Department: "+department);
        System.out.println();
        System.out.println("Basic Salary: "+basic_salary);

    }

    float hra(){
         float hra=(float)(basic_salary*house)/100;
         return hra;
    }

    float da(){
         float da=(float)(basic_salary*dearness)/100;
         return da;
    }

    float ma(){
        System.out.print("Medical allowance: ");
        return 1500;
    }

    float pf(){
         float pf=(float)(basic_salary*provident)/100;
         return pf;
    }

    float gs(){
         float gs=basic_salary+hra()+da()+ma();
         return gs;
    }

    float ns(){
         float ns= gs()-pf();
         return ns;
    }

}

public class Salary {
    public static void main(String[] args) {
      Employee ob=new Employee();
      ob.employee_detail();
        System.out.println();
      ob.display();
        System.out.println("House Rent Allowance: "+(ob.hra()));
        System.out.println("Dearness Allowance: "+(ob.da()));
        System.out.println(ob.ma());
        System.out.println("Provident Fund: "+(ob.pf()));
        System.out.println();
        System.out.println("Gross Salary: "+(ob.gs()));
        System.out.println("Net Salary: "+(ob.ns()));
    }
}

Suman11Gupta avatar Jul 24 '24 14:07 Suman11Gupta




package loop_nested;



import java.util.Scanner;

class salary_system {
        int salary,gs,ns;
        float HRA,DA,PF,MA=1500;
        String name,id,designation,department;
    void input(){
        Scanner scanner=new Scanner(System.in);
        System.out.print("Enter the name: ");
        name=scanner.next();
        System.out.print("Id: ");
        id=scanner.next();
        System.out.print("Designation: ");
        designation=scanner.next();
        System.out.print("Enter the Department: ");
        department=scanner.next();
        System.out.print("Enter the Salary: ");
         salary=scanner.nextInt();
    }

    float HRA(){
        HRA=salary*20/100;
        return HRA;
    }
    float DA(){
        DA=salary*10/100;
        return DA;
    }
    float PF(){
        PF=salary*12/100;
        return PF;
    }
    int gs(){
        gs= (int) (salary+HRA+DA+PF+MA);
        return gs;
    }
    int ns(){
        ns=(int)(gs()-PF());
                return ns;
    }





    void Output(){
        System.out.println("Employee Salary Details");
        System.out.println("-----------------------");
        System.out.println("Name: "+name);
        System.out.println("ID: "+id);
        System.out.println("Designation: "+designation);
        System.out.println("Department: "+department);
        System.out.println();
        System.out.println("Basic Salary: "+salary);
        System.out.println("House Rent Allowance (HRA): "+ HRA());
        System.out.println("Dearness Allowance (DA): "+DA());
        System.out.println("Medical Allowance:"+MA);
        System.out.println("Provident Fund (PF): "+PF());
        System.out.println();
        System.out.println("Gross Salary: "+gs());
        System.out.println("Net Salary: "+ns());
    }







    public static void main(String[] args) {
        salary_system ss=new salary_system();
        ss.input();
        ss.Output();

        }
    }


AlokSingh100 avatar Jul 25 '24 12:07 AlokSingh100

package Assignment;
import java.util.Scanner;
public class Advance_salary_system {
     
	static String name , id,designation,department;
	 static int  basic_salary , GS,NS;
	 float hra,da,pf,HRA1,DA,PF,MA;
	public static void main(String[] args) {
		Advance_salary_system ob = new Advance_salary_system();
		ob.input();
		ob.output();
		
	}

	void input()
	
	{
		Scanner sc = new Scanner(System.in);
		System.out.print("Enter your name:");
		name = sc.next();
		System.out.print("Enter your ID:");
		id = sc.next();
		System.out.print("Enter your Basic Salary:");
		basic_salary = sc.nextInt();
		System.out.print("Enter your Designation:");
		designation = sc.next();
		System.out.print("Enter your Department:");
		department = sc.next();
		System.out.print("Enter house rent allowance:");
		hra = sc.nextFloat();
		System.out.print("Enter dearness allowance:");
		da = sc.nextFloat();
		
		System.out.print("Enter  provident fund:");
		pf = sc.nextFloat();
		
	}
	
	void output()
	{
		 System.out.println("Employee Salary Details");
		 System.out.println("________________________");
		 System.out.println("Name: "+name);
		 System.out.println("ID: "+id);
		 System.out.println("Designation: "+designation);
		 System.out.println("Department: "+department);
		 System.out.println();
		 System.out.println("Basic Salary: "+basic_salary );
		 System.out.println("House Rent Allowance "+HRA1() );
		 System.out.println("Dearness Allowance: "+DA() );
		 System.out.println("Medical Allowance: "+MA());
		 System.out.println("Provident Fund: "+PF() );
		 System.out.println();
		 System.out.println("Gross Salary: "+GS() );
		 System.out.println("Net Salary: "+NS() );
		
	}
	
	float HRA1()
	{
		float HRA1=basic_salary*hra/100;
		return HRA1;
	}
	float DA()
	{
		float DA=basic_salary*da/100;
		return DA;
	}
	float PF()
	{
		float PF=basic_salary*pf/100;
		return PF;
	}
		int MA()
		{
			
			return 1500;
	}
	int GS()
	{
		 GS=(int)(basic_salary+HRA1()+DA()+MA()+PF());
		return GS;
	}
	int NS()
	{
		 NS=(int)(GS()-PF());
		return NS;
	}
	
	
	
	
	

}

JanhaviSatam avatar Jul 26 '24 11:07 JanhaviSatam

package June_22;
import java.util.Scanner;
public class Employee {
    String name, id, designation, department;
    int salary, med = 1500;
    float hra, da, pf, gs, ns;
    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        Employee emp = new Employee();
        emp.data();
        emp.HouseRent();
        emp.DA();
        emp.PF();
        emp.Medical();
        emp.grossSalary();
        emp.netSalary();
        System.out.println();
        System.out.println("|----------------------|");
        System.out.println("|Employee Salary Detail|");
        System.out.println("|----------------------|");
        System.out.println();
        emp.op();

    }

    void data() {
        while (true) {
            System.out.print("Enter Your Name:");
            name = sc.nextLine();
            if (!name.isEmpty()) {
                break;
            }
                else {
                System.out.println("Name cannot be empty");
            }

        }

            System.out.print("Enter Your ID:");
            id = sc.next();
            System.out.print("Enter your Basic Salary:");
            salary = sc.nextInt();
            while(salary<0){
            System.out.println("Salary must be in positive number");
            System.out.print("Enter your Basic Salary:");
            salary = sc.nextInt();
            }
            System.out.print("Enter Your Designation:");
            designation = sc.next();
            System.out.print("Enter Your Department:");
            department = sc.next();
    }
    float HouseRent(){
        hra=(salary*20/100);
        return hra;
    }
    float DA(){
        da=(salary*10/100);
        return da;
    }
    float PF(){
        pf=(salary*12/100);
        return pf;
    }
    int Medical(){
        return med;
    }
    float grossSalary(){
        gs=salary+hra+da+med;
        return gs;
    }
    float netSalary(){
        ns=gs-pf;
        return ns;
    }
    void op(){
        System.out.println("Name:"+name);
        System.out.println("Id:"+id);
        System.out.println("Designation:"+designation);
        System.out.println("Department:"+department);
        System.out.println("Basic Salary:"+salary);
        System.out.println("House Rent Allowance (HRA):"+hra);
        System.out.println("Dearness Allowance (DA):"+da);
        System.out.println("Provident Fund (PF):"+pf);
        System.out.println("Medical Allowance:"+med);
        System.out.println("Gross Salary:"+gs);
        System.out.println("Net Salary:"+ns);
    }

}

Moumita0710 avatar Jul 27 '24 09:07 Moumita0710

import java.util.Scanner;

class Employee {
    Scanner sc = new Scanner(System.in);
    String name, designation, department;
    int id;
    int salary;
    int hra, dearness, pf, medical;

    public void detail() {
        System.out.println("enter the name of employee: ");
        name = sc.next();
        System.out.println("enter the id of employee: ");
        id = sc.nextInt();
        System.out.println("enter the basic salary of employee: ");
        salary = sc.nextInt();
        System.out.println("enter the designation of employee: ");
        designation = sc.next();
        System.out.println("enter the department of employee: ");
        department = sc.next();
    }
    public void salary_compo() {

        System.out.println("enter the hra allowance%: ");
        hra = sc.nextInt();
        System.out.println("enter the dearness allowance %: ");
        dearness = sc.nextInt();
        System.out.println("enter the provident fund :%: ");
        pf = sc.nextInt();
        System.out.println("medical allowance amount: ");
        medical = sc.nextInt();

        System.out.println();
        System.out.println();
    }

    public void display() {
        System.out.println("......Employee Salary Details......");
        System.out.println("............................................");
        System.out.println("Employee Name  : " + name);
        System.out.println("Employee ID  :" + id);
        System.out.println("Employee Designation  :" + designation);
        System.out.println("Employee Department  :" + department);
    }

    int salary_calc1() {
        int dearness_amount = (salary * dearness / 100);
        return dearness_amount;
    }

    int salary_calc2() {
        int pf_amount = (salary * pf / 100);
        return pf_amount;

    }

    int salary_calculate() {
        int hra_amount = (salary * hra / 100);
        return hra_amount;
    }
    public void display1() {
        System.out.println();
        System.out.println();
        System.out.println("Basic Salary :" + salary);
        System.out.println("Medical Amount ;" + medical);

    }
    int gross_salary() {
        int gross_salar = salary + salary_calculate() + salary_calc1() + medical;
        return gross_salar;


    }
    int net_salary(){
        int net_salar=gross_salary()-  salary_calc2();
        return net_salar;
    }

}
public class Salary_System {
    public static void main(String[] args) {
        Employee emp = new Employee();
        System.out.println("..............Employee Details.....................");
        emp.detail();
        emp.salary_compo();
        emp.display();
        System.out.println();
        System.out.println();
        System.out.println("Employee Basic Salary  :" + emp.salary);
        System.out.println("House Rent Allowance(HRA) :"+emp.salary_calculate());
        System.out.println("Dearness Allowance(DA) :" + emp.salary_calc1());
        System.out.println("Provident Fund(PF) :" +emp.salary_calc2());
        System.out.println();
        System.out.println();
        System.out.println("gross_salary: "+emp.gross_salary());
        System.out.println("Net salary : "+emp.net_salary());
    }
}

shubh9819 avatar Jul 30 '24 12:07 shubh9819


import java.util.Scanner;

public class salary_system {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String name,id,monthselect;
		int CTC;
		int salary,month,monthDay=0,year,leaves,Conveyance,Medical,OtherA,ProfessionalAmount,monthnetsalary,TotalDeductions,netsalary,PaidD;
		monthselect="";
		System.out.println("Enter the name:");
        name=sc.next();
        System.out.println("Enter the employee id:");
        id=sc.next();
        System.out.println("Enter the Current Year:");
        year =sc.nextInt() ;
        System.out.print("Enter the Leaves Taken IN this Month: ");
        leaves =sc.nextInt() ;
        System.out.print("Enter the monthly Salary : ");
        salary =sc.nextInt() ;
        System.out.print("Enter the Conveyance Allowance in Percentage: ");
        Conveyance =sc.nextInt() ;
        System.out.print("Enter the Medical Allowance in Percentage: ");
        Medical =sc.nextInt() ;
        System.out.print("Enter the Other Allowances in Percentage: ");
        OtherA =sc.nextInt() ;
        System.out.print("Enter the Professional Tax in Percentage: ");
        ProfessionalAmount =sc.nextInt() ;
        System.out.print("Enter the Current Month: ");
        month =sc.nextInt();
        switch (month) {
        case 1:
        monthDay = 31;
        monthselect = "January";
        break;
        case 2:
        if ((year % 400 == 0) || ((year % 100 != 0) && (year % 4 == 0))) {
        monthDay = 29;
        } else monthDay = 28;
        monthselect = "February";
        break;
        case 3:
        monthDay = 31;
        monthselect = "March";
        break;
        case 4:
        monthDay = 30;
        monthselect = "April";
        break;
        case 5:
        monthDay = 31;
        monthselect = "May";
        break;
        case 6:
        monthDay = 30;
        monthselect = "June";
        break;
        case 7:
        monthDay = 31;
        monthselect = "July";
        break;
        case 8:
        monthDay = 31;
        monthselect = "August";
        break;
        case 9:
        monthDay = 30;
        monthselect = "September";
        break;
        case 10:
        monthDay = 31;
        monthselect = "October";
        break;
        case 11:
        monthDay = 30;
        monthselect = "November";
        break;
        case 12:
        monthDay = 31;
        monthselect = "December";
        break;
        default:
        System.out.println("enter Between 1 to 12 ");
        }
        //calculation
        PaidD=monthDay-leaves;
        leaves=(int) ((float)(salary/monthDay)*(leaves));
        salary=salary*12;
        Conveyance=(int) ((float) salary*Conveyance/100);
        OtherA=(int) ((float) salary*OtherA/100);
        Medical=(int) ((float) salary*Medical/100);
        TotalDeductions=Conveyance+OtherA+Medical;
        monthnetsalary=TotalDeductions/12 ;
        CTC=salary+TotalDeductions;
        monthnetsalary=salary-leaves;
        ProfessionalAmount=(int) ((float) monthnetsalary*ProfessionalAmount/100);
        TotalDeductions=leaves+ProfessionalAmount;
        netsalary=monthnetsalary+monthnetsalary-TotalDeductions;
        System.out.println();
        System.out.println();
        System.out.println("------Output---------");
        System.out.println();
        System.out.println();

        System.out.println("Employee Name= " +name);
        System.out.println("Employee Id ="+ id);
        System.out.println("Paid Days = "+ PaidD);
        System.out.println("Basic Salary= "+ salary);
        System.out.println("Total Working Days = "+ monthDay);
        System.out.println("Leaves Amount ="+ leaves);
        System.out.println("Conveyance Allowance ="+ Conveyance);
        System.out.println("Other Allowance ="+ OtherA);
        System.out.println("Medical Allowance ="+ Medical);
        System.out.println("CTC =" + CTC);
        System.out.println("Total Allowance =" +TotalDeductions);
        System.out.println("Professional Tax = " + ProfessionalAmount);
        System.out.println("Total Deductions = "+ TotalDeductions);
        System.out.println("Net Salary = " +netsalary);
        System.out.println("Month = " +monthselect+"/"+year);
        }
        
	

}





omkaraair20 avatar Sep 16 '24 13:09 omkaraair20