Computer Science, asked by adwaithsajikumar4111, 5 months ago

1.Sponge iron company announces an increment for their employees on seniority basis as per the given conditions.
Age Increment
56years and above 20% of basic
Above 45 and below 56 years 15% of basic
Upto 45 10% of basic

Write a program to find new basic by using the following class specifications.
Class : Increment
Data members:
String name : Name of the employee.
double basic : Basic pay of the employee.
Int age : Age of the employee.
Member Methods:
void getdata( String n, double b, int a):To accept name, basic and age of the employee.
void calculate( ):To find increment and update basic.
void display():To display age and updated basic in the format given below:
Name Age Updated Basic
Xxxxx xxx xxxxxxxxxxxxx

Answers

Answered by shilpa85475
6

Age Increment

56years and above 20% of basic

Above 45 and below 56 years 15% of basic

Up to 45 10% of basic

Explanation:

import java.util.Scanner;

public class Employee

{

   private int pan;

   private String name;

   private double taxincome;

   private double tax;

   

   public void input() {

       Scanner in = new Scanner(System.in);

       System.out.print("Enter pan number: ");

       pan = in.nextInt();

       in.nextLine();

       System.out.print("Enter Name: ");

       name = in.nextLine();

       System.out.print("Enter taxable income: ");

       taxincome = in.nextDouble();

   }

   

   public void cal() {

       if (taxincome <= 250000)

           tax = 0;

       else if (taxincome <= 500000)

           tax = (taxincome - 250000) * 0.1;

       else if (taxincome <= 1000000)

           tax = 30000 + ((taxincome - 500000) * 0.2);

       else

           tax = 50000 + ((taxincome - 1000000) * 0.3);

   }

   

   public void display() {

       System.out.println("Pan Number\tName\tTax-Income\tTax");

       System.out.println(pan + "\t" + name + "\t"  

           + taxincome + "\t" + tax);

   }

   

   public static void main(String args[]) {

       Employee obj = new Employee();

       obj.input();

       obj.cal();

       obj.display();

   }

}

Answered by sreastharanjan001
0

Answer:

import java.util.Scanner;

class Increment

{

   String name;

   double basic;

   int age;

   void getdata(String n, double b, int a)

   {

       name=n;

       basic=b;

       age=a;

   }

   void calculate()

   {

       if(age<=45)

           basic=basic+(0.1*basic);

       else if(age<56)

           basic=basic+(0.15*basic);

       else

           basic=basic+(0.2*basic);    

   }

   void display()

   {

       System.out.println("Name\tAge\tUpdated Basic");

       System.out.println(name+"\t"+age+"\t"+basic);

   }

   public static void main() {

       Scanner sc=new Scanner(System.in);

       Increment ob=new Increment();

       System.out.println("Enter the Name, Age and Basic Pay of the Employee:");

       String x=sc.next();

       int y=sc.nextInt();

       double z=sc.nextDouble();

       ob.getdata(x,z,y);

       ob.calculate();

       ob.display();

   }

}

Similar questions