Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. package employee;
  2. import java.util.Scanner;
  3.  
  4. public class Employee
  5. {
  6.  
  7. //Fields
  8. private String name;
  9. private double salary;
  10.  
  11. //Accessor Methods & Mutator Methods
  12. public String getName() {return name;}
  13. public void setName(String name) {this.name = name;}
  14.  
  15. public double getSalary() {return salary;}
  16. public void setSalary(double salary) {this.salary = salary;}
  17.  
  18. public static void main(String[] args)
  19. {
  20. Scanner keyboard = new Scanner(System.in);
  21. Employee n = new Employee();
  22. Employee j = new Employee();
  23. //Employee 1
  24.  
  25. System.out.println("Enter the name of the first employee and their hourly salary.");
  26. n.setName(keyboard.nextLine());
  27. n.setSalary(keyboard.nextDouble());
  28.  
  29. //Employee 2
  30. System.out.println("Enter the name of the second employee and their hourly salary.");
  31. j.setName(keyboard.nextLine());
  32. j.setSalary(keyboard.nextDouble());
  33.  
  34.  
  35. System.out.printf("%s -- %.2f\n%s -- %.2f\n",
  36. n.getName(), n.getSalary(), j.getName(), j.getSalary());
  37.  
  38. }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement