The code below is a section of a target program that just wi
Solution
1. Create a container/frame.
2. Specify the layout to be used in the container.
3. Create component.
4. Create an actionlister.
5. add component to container
6. add component to the actionlister
package bookserial;
import java.io.File;
import java.util.Scanner;
public class Employee {
private String name;
private int yearsOfService;
private double hourlyRate;
/**
* @param name
* @param yearsOfService
* @param hourlyRate
*/
public Employee(String name, int yearsOfService, double hourlyRate) {
this.name = name;
this.yearsOfService = yearsOfService;
this.hourlyRate = hourlyRate;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the yearsOfService
*/
public int getYearsOfService() {
return yearsOfService;
}
/**
* @param yearsOfService
* the yearsOfService to set
*/
public void setYearsOfService(int yearsOfService) {
this.yearsOfService = yearsOfService;
}
/**
* @return the hourlyRate
*/
public double getHourlyRate() {
return hourlyRate;
}
/**
* @param hourlyRate
* the hourlyRate to set
*/
public void setHourlyRate(double hourlyRate) {
this.hourlyRate = hourlyRate;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return \"Employee [name=\" + name + \", yearsOfService=\" + yearsOfService
+ \", hourlyRate=\" + hourlyRate + \"]\";
}
public static void main(String[] args) {
Scanner scanner = null;
try {
File file = new File(\"curr_employees.txt\");
scanner = new Scanner(file);
Employee employee = new Employee(scanner.next(), scanner.nextInt(),
scanner.nextDouble());
System.out.println(employee);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
} finally {
if (scanner != null) {
scanner.close();
}
}
}
}
curr_employees.txt
Srinivas 6 22.50
OUTPUT:
Employee [name=Srinivas, yearsOfService=6, hourlyRate=22.5]


