Skip to main content

Java Program to make Employee Record

Employee Record 





First is the Employee Class:-

public class Employee


 private String firstName; 
 private String lastName; 
 private double monthlySalary; 

 public Employee(String f, String l, double m)
 {
 firstName = f;     
 lastName = l;     
 if(m < 0){
 monthlySalary =0;   
 }     
 else
 {
 monthlySalary = m; 
 }
 }

    public String getFirstName()
{     
return firstName;
    }

    public void setFirstName(String fname)
{
firstName = fname;
    }

    public String getLastName()
{   
return lastName; 

public void setLastName(String lname)
{   
    lastName = lname; 
}

public double getMonthlySalary()
{   
    return monthlySalary; 
}   
    public void setMonthlySalary(double m)
{     
if(m < 0)

monthlySalary =0;     
}     
else
{
monthlySalary = m;
}

}
}



Second is the Main Class To execute the Code :-


import java.util.Scanner;


public class EmployeeTest
 {
 public static void main(String[] args)
 {

 Scanner S = new Scanner(System.in); 
 System.out.println("Enter the first name employee 1 ");
 String fname = S.next();   
 System.out.println("Enter the last name:employee 1 ");
 String lname = S.next();
 System.out.println("Enter the Salary:employee 1 ");
 double sal = S.nextDouble(); 
 Employee e =new Employee(fname,lname ,sal );

System.out.println("the yearly salary of employee 1"+e.getFirstName()+" "   +e.getLastName()+" :");
 System.out.println(e.getMonthlySalary()*12);

double newsalary= e.getMonthlySalary()*0.1+e.getMonthlySalary();     
  e.setMonthlySalary(newsalary);   
  System.out.println("the new yearly salary of employee 1 "+ e.getFirstName()+" "+e.getLastName()+" :");
  System.out.println(e.getMonthlySalary()*12);   
  e.getMonthlySalary();


 System.out.println("Enter the first name employee 2");
  fname = S.next();   
 System.out.println("Enter the last name:employee 2");
 lname = S.next();
 System.out.println("Enter the Salary:employee 2");
 sal = S.nextDouble(); 
 Employee e2=new Employee(fname,lname ,sal );

System.out.println("the yearly salary of employee 2"+e2.getFirstName()+" "   +e2.getLastName()+" :");
 System.out.println(e2.getMonthlySalary()*12);

 newsalary= e2.getMonthlySalary()*0.1+e2.getMonthlySalary();   
  e2.setMonthlySalary(newsalary); 
  System.out.println("the new yearly salary of employee 2"+ e2.getFirstName()+" "+e2.getLastName()+" :");
  System.out.println(e2.getMonthlySalary()*12);   
  e2.getMonthlySalary();

    }
 }

Comments

Popular posts from this blog

a speculative study of bscs

BSCS STUDENTS AND A CONTEMPORARY FIELD: A SPECULATIVE STUDY TABLE OF CONTENTS EXECUTIVE SUMMARY……………………………………………………………………….4 HISTORY…………………………………………………………………………………………5-6 MODERN TRENDS………………………………………………………………………………7-8 INTRODUCTION…………………………………………………………………………………8 PROCEDURES……………………………………………………………………………………8 METHADOLOGY--------------------------------------------------------------------------------------------9 THEORY OF COMPUTER SCIENCE--------------------------------------------------------------------9 THEORY OF COMPUTATION----------------------------------------------------------------------------10 ALGORITHAM & DATA STRUCTURE-----------------------------------------------------------------10 PROGRAMMING LANGUAGE THEORY---------------------------------------------------------------10 FINDINGS…………………………………………………………………………………………11-14 ANALYSIS………………………………………………………………………………………..15 RECOMMENDATIONS………………………………………………………………………….15 CONCLU...

Technology

Virtual Reality The Next Upcoming Domain in Pakistan is VIRTUAL REALITY and people are making themselves obsessed with it because it takes your imagination to what you are seeing through VR gadget as we know the technology is going to boom in Pakistan through last few years.

Cricket Match

Finally International Cricket again hit the Grounds of Pakistan  Now in Pakistan the Best thing is to about the start of International cricket. Finally the cricket hits the Ground of Pakistan with this phase of  WORLD IX vs PAKISTAN. The schedule is for three days continuous 12 , 13 , 14 September 2017. The all matches will be play in Gaddafi Stadium Lahore , as a FINAL of PSL 02 was also held there.The recent picture is as shown below from Lahore Stadium Cricket is one of the most favourite game of Pakistani's and we love cricket more than our National game because all we like to say that         ↪ "YAR CRICKET LOVE HAI''  We Pakistani's consider to be the most craziest fan's of CRICKET. As we are also moving towards PSL 03 and all the matches are probably be going to Play in Pakistan. The more is coming to pakistan with the passage of time we are moving forward to Meet the International Cricket Standards. Wish All the Be...