Sunday, August 18, 2019

BlueJ Program on Basic Hra Da


BlueJ program on Basic, DA, HRA etc calculations.

Write a program using a class with the following specifications

Class Name: Salary
Data Members: String name, dept, desig, firm;
                          double basic, da,hrs, cta,pf, gross;
Member Methods:  void input () To accept the name, department, designation, firm, basic
                                 void calculate () To calculate the following
(h)          DA = 30% of basic
(i)            HRA = 20% of basic
(j)            CTA = 15% of basic
(k)          PF = 8.33% of basic
(l)            Gross=basic + DA + HRA + CTA – PF
              void display ()  To display the following
Name
Department
Designation
Firm
Gross Salary
         


import java.util.*;
public class Salary
{
    Scanner sc=new Scanner(System.in);
    String name, dept, desig, firm;
    double basic, da,hra, cta,pf, gross;
   
    public void input()
    {           
            System.out.print("\nEnter Name:");
            name=sc.nextLine();
            System.out.print("\nEnter Department:");
            dept=sc.nextLine();
            System.out.print("\nEnter Designation:");
            desig=sc.nextLine();
            System.out.print("\nEnter Firm Name:");
            firm=sc.nextLine();
            System.out.print("\nEnter Basic:");
            basic=sc.nextDouble();
        }
        public void calculate ()
        {
           
           da = 30/100.00 * basic;
            hra = 20/100.00 * basic;
            cta = 15/100.00 * basic;
            pf = 8.33/100 * basic;
            gross=basic + da + hra + cta - pf;
       
    }
            public void display ()
        {
                   System.out.println("\nName:"+name);
                   System.out.println("\nDepartment:"+dept);
                   System.out.println("\nDesignation:"+desig);
                   System.out.println("\nFirm Name:"+firm);
                   System.out.println("\nGross Salary:"+gross);
                }
            public static void main(String args[])
            {
                 Salary obj=new Salary();
                 obj.input();
                 obj.calculate();
                 obj.display();
             }
            }

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner