Part 1: Exceptions
You will use the Circle class given in lecture for this assignment.
Write a class CircleMain3. Inside the main method of this class, prompt
the user to enter the radius values for 5 circles, use the Circle
class to create the Circles, and use the area() method of the Circle
class
to print the area of each circle (with a positive radius) to the
screen.
Your program should prompt the user to enter additional radius values
until
5 positive values are entered. This part of the project should be
submitted
electronically. Submit files Circle.java and CircleMain3.java.
For this assignment, we will use the turnin procedure (please see the instructions for using the turnin procedure on the class web page). The files you should submit are:
Employee.java
Boss.java
TestEmployee.java
employee.txt
Write an Employee class. The public methods in this class should be:
1. A constructor that takes the first name, last name, monthly salary
(a double) as arguments.
2. A getFirstName method that returns the first name of the employee.
3. A getLastName method that returns the last name of the employee.
4. A toString method that returns the first and last name of the
employee
separated by a space.
5. An earnings method that returns the employee's annual salary.
Write a Boss class that inherits from Employee. The public methods
of
the class should be:
1. A constructor that takes a first name, last name, monthly salary
and annual bonus as arguments, and passes the first name, last name and
monthly salary to the Employee's constructor to initialize its
firstName,
lastName, and monthly salary members.
2. An earnings method that returns the boss's annual income (annual
salary + bonus).
3. A toString method that returns a String containing the type of
employee
(i.e. "Boss: ") followed by the boss's name.
The data members of both the Employee class and Boss class should be private.
Write a TestEmployee class to test these two classes. Your TestEmployee class will read employee information from a text file called "employee.txt" with the following format:
<number indicating whether or not employee 1 is a boss -- 0 = no,
1= yes>
<employee 1's first name>
<employee 1's last name>
<employee 1's monthly salary>
<employee 1's annual bonus, if employee 1 is a boss>
<number indicating whether or not employee 2 is a boss>
.
.
.
For example, your file might look like this:
0
Sam
Smith
1200.56
1
Harry
Hacker
5800.21
3000.50
The TestEmployee class assigns the information for each employee to an Employee instance, and prints a list of employees to the screen using the appropriate methods in the other two classes. That is, do NOT read the information from the file and then just print it to the screen; read the employee information from the file, and store it in an Employee instance. Then display the desired information from the Employee instance by using the Employee methods.
Sample Output:
Sam Smith
annual earnings: $25000
Boss: Harry Hacker
annual earnings: $70000
Boss: Tiger Woods
annual earnings: $500000
Your class should process all employees represented in the file in this way. Turn in the "employee.txt" file that you use to test your program. You will be graded in part on how thoroughly you tested your program.
Each class should contain documentation that states your name, social security number, and a brief description of the class. Variables should have meaningful names, and you should include comments as needed to improve readability of your program.
For I/0, you must use methods from the java.io package.