Employ Gross Salary coderinme

Employ Gross Salary coderinme

In a small firm employee numbers are given in serial numerical order, that is 1, 2, 3 etc.
write a menu driven program to perform following operations:
a) Create a file of employee data with following information:
Employee No, Name, Sex, Gross Salary.
b) Append the data of a new employee joining the firm.
c) If a given employee leaves, delete his record.
d) If gross salary of a given employee increases, update the gross salary.
e) Display the record of (i) a given employee or (ii) all employees.
Program:

import java.io.*;
class Employee 
{
protected String name;
protected String id;
protected String dept;
protected double salary;
public Employee() 
{
name=null;
id=null;
dept=null;
salary=0.0;
}
public Employee(String name,String id,String dept,double salary) 
{
this.name=name;
this.id=id;
this.dept=dept;
this.salary=salary;
}
public String toString() 
{
return "Name:"+name+",id:"+id+",dept:"+dept+",salary:"+salary;
}
}
class Manager extends Employee 
{
private double bonus;
public Manager(String name,String id,String dept,double salary,double bonus) 
{
super(name,id,dept,salary);
this.bonus=bonus;
}
public String toString() 
{
return super.toString()+",bonus:"+bonus;
}
public void finalSalary() 
{
salary=salary+bonus;
}
public static int max(Manager[] a) 
{
double max=a[0].salary;
int j=0,i;
for(i=0;i<a.length;i++) 
{
if(max<a[i].salary) 
{
max=a[i].salary;
j=i;
}
}
return j;
}
}
public class Q20 
{
public static void main(String[] args) throws IOException 
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.println("please tell me the number of records :");
int n=Integer.parseInt(in.readLine());
int i; String name,id,dept; double salary,bonus;
Manager a[]=new Manager[n];
for(i=0;i<n;i++) 
{
System.out.println("input the name of the employee no :"+(i+1));
name=in.readLine();
System.out.println("input the id of the employee:");
id=in.readLine();
System.out.println("input the dept of the employee:");
dept=in.readLine();
System.out.println("input the salary of the employee:");
salary=Double.parseDouble(in.readLine());
System.out.println("input the bonus of the employee:");
bonus=Double.parseDouble(in.readLine());
a[i]=new Manager(name,id,dept,salary,bonus);
a[i].finalSalary();
}
for(i=0;i<n;i++)
System.out.println(a[i]);
int k=Manager.max(a);
System.out.println("Details of Manager with highest salary :\n"+a[k]);
} 
}

For more programs on Java, visit our Java Archives

employee bonus

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.