Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package employee;
- import java.util.Scanner;
- public class Employee
- {
- //Fields
- private String name;
- private double salary;
- //Accessor Methods & Mutator Methods
- public String getName() {return name;}
- public void setName(String name) {this.name = name;}
- public double getSalary() {return salary;}
- public void setSalary(double salary) {this.salary = salary;}
- public static void main(String[] args)
- {
- Scanner keyboard = new Scanner(System.in);
- Employee n = new Employee();
- Employee j = new Employee();
- //Employee 1
- System.out.println("Enter the name of the first employee and their hourly salary.");
- n.setName(keyboard.nextLine());
- n.setSalary(keyboard.nextDouble());
- //Employee 2
- System.out.println("Enter the name of the second employee and their hourly salary.");
- j.setName(keyboard.nextLine());
- j.setSalary(keyboard.nextDouble());
- System.out.printf("%s -- %.2f\n%s -- %.2f\n",
- n.getName(), n.getSalary(), j.getName(), j.getSalary());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement