Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Introduction to Java Problem 1: Implement a class called BonusTooHighException, designed to be thrown when a bonus value is more than $10000. Using the Executive

Introduction to Java

Problem 1:

Implement a class called BonusTooHighException, designed to be thrown when a bonus value is more than $10000. Using the Executive class from Chapter 10, create a main program that creates and populates an Executive array with information entered by the user (array size as well). If a bonus value is entered that is too high, i.e. more than $10000 throw the exception. Allow the thrown exception to terminate the program.

Problem 2:

Modify the solution to the program above (submit a second file for this) such that it catches and handles the exception if it is thrown. Handle the exception by printing an appropriate message and keeping the bonus=0, and then continue entering more executive data. Let the program conclude by printing the total number of executives with valid bonuses, i.e. positive, no more than $10000 as well as the average pay.

NOTE: These problems do not require use of all the classes from Chapter 10.

Since Executive is a child of Employee, StaffMember,you can copy them to your homework folder.

//********************************************************************

// Executive.java

//

// Represents an executive staff member, who can earn a bonus.

//********************************************************************

public class Executive extends Employee

{

private double bonus;

//-----------------------------------------------------------------

// Constructor: Sets up this executive with the specified

// information.

//-----------------------------------------------------------------

public Executive(String eName, String eAddress, String ePhone,

String socSecNumber, double rate)

{

super(eName, eAddress, ePhone, socSecNumber, rate);

bonus = 0; // bonus has yet to be awarded

}

//-----------------------------------------------------------------

// Awards the specified bonus to this executive.

//-----------------------------------------------------------------

public void awardBonus(double execBonus)

{

bonus = execBonus;

}

//-----------------------------------------------------------------

// Computes and returns the pay for an executive, which is the

// regular employee payment plus a one-time bonus.

//-----------------------------------------------------------------

public double pay()

{

double payment = super.pay() + bonus;

bonus = 0;

return payment;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions