Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mns;
- import java.util.Scanner;
- public class Employee {
- private String firstName;
- private String lastName;
- private double monthlySalary;
- public Employee() {
- firstName = null;
- lastName = null;
- monthlySalary = 0.0;
- }
- public String getfirstName() {
- return firstName;
- }
- public String getlastName() {
- return lastName;
- }
- public double getSalary() {
- return monthlySalary;
- }
- public void setfirstName(String first) {
- firstName = first;
- }
- public void setlastName(String last) {
- lastName = last;
- }
- public void setSalary(double salary) {
- monthlySalary = salary;
- }
- public static void main(String args[]) {
- Employee em1 = new Employee();
- Employee em2 = new Employee();
- Scanner inp = new Scanner(System.in);
- String first;
- String last;
- double salary;
- System.out.println("Enter First Name of 1st Employee: ");
- first = inp.next();
- em1.setfirstName(first);
- System.out.println("Enter Last Name of 1st Employee: ");
- last = inp.next();
- em1.setlastName(last);
- System.out.println("Enter Monthly Salary of 1st Employee: ");
- salary = inp.nextDouble();
- em1.setSalary(salary);
- System.out.println("Enter First Name of 2nd Employee: ");
- first = inp.next();
- em2.setfirstName(first);
- System.out.println("Enter Last Name of 2nd Employee: ");
- last = inp.next();
- em2.setlastName(last);
- System.out.println("Enter Monthly Salary of 2nd Employee: ");
- salary = inp.nextDouble();
- em2.setSalary(salary);
- System.out.println("1st Employee's Full Name and Yearly Salary.\n");
- System.out.println(em1.getfirstName() + " " + em1.getlastName() + " " + em1.getSalary() * 12 + "\n");
- System.out.println("2nd Employee's Full Name and Yearly Salary.\n");
- System.out.println(em2.getfirstName() + " " + em2.getlastName() + " " + em2.getSalary() * 12 + "\n");
- System.out.println("New Annual Salary After 10% Raise\n");
- System.out.println(em1.getfirstName() + " " + em1.getlastName() + " " + (em1.getSalary() * 1.10 * 12 + "\n"));
- System.out.println(em2.getfirstName() + " " + em2.getlastName() + " " + (em2.getSalary() * 1.10 * 12 + "\n"));
- }
Advertisement
Add Comment
Please, Sign In to add comment