Class 10th ICSE

Q.3

Define a class Employee with the following description:
Instance variables/Data members:
int pan – to store the personal account number
String name – to store the name
double taxincome – to store annual taxable income
double tax – to store the tax that is calculated
Member methods:
Employee()-Default constructor to store null to member data
void input()-fill values in member data pan,name,tax income
void calc()-calculate tax for an employee and store in tax.
void display()- output member data, and also the income after tax deduction
The following chart is given for tax calculation:
Annual taxable income Tax rate
<=100000 No tax
>100000 and <=500000 8% of the income exceeding 100000

>500000 and <=1200000 12% of the income exceeding 500000
>1200000 16% of the income exceeding 1200000

Solution :- 

import java.util.*;

class p3{

    Scanner sc=new Scanner(System.in);

    int pan;

    String name;

    double taxincome,tax;

    p3(){

        pan=0;

        name=””;

        taxincome=0.0;

        tax=0.0;

    }

    void input(){

        System.out.println(“Enter name of the employee”);

        name=sc.nextLine();

        System.out.println(“Enter personal account number of the employee”);

        pan=sc.nextInt();

        System.out.println(“Enter tax income of the employee”);

        taxincome=sc.nextDouble();

    }

    void calc(){

        if(taxincome<=100000)

        tax=0.0;

        else if(taxincome>100000 && taxincome<=500000)

        tax=(taxincome-100000)*0.08;

        else if(taxincome>500000 && taxincome<=1200000)

        tax=(400000*0.08)+(taxincome-500000)*0.12;

        else if(taxincome>1200000)

        tax=(400000*0.08)+(700000*0.12)+(taxincome-1200000)*0.16;

    }

    void display(){

        System.out.println(“Name of the employee=”+name);

        System.out.println(“Personal account number of employee=”+pan);

        System.out.println(“Tax income of the employee=”+taxincome);

        System.out.println(“Tax of the employee=”+tax);

    }

    public static void main(){

        p3 obj=new p3();

        obj.input();

        obj.calc();

        obj.display();

    }

    }

Output :-

Fun & Easy to follow
Works on all devices
Your own Pace
Super Affordable

Popular Videos

Play Video

UX for Teams

Learn the basics and a bit beyond to improve your backend dev skills.

ava4.png
Chris Matthews

Designer

Play Video

SEO & Instagram

Learn the basics and a bit beyond to improve your backend dev skills.

ava4.png
Chris Matthews

Designer