Java: An Introduction to Problem Solving and Programming (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 8, Problem 9E

Explanation of Solution

 Implementation of the derived class “RegularPay”:

The implementation of the derived class “RegularPay” is given below:

  • • The “RegularPay” class is derived from the “PayCalculator” abstract class as discussed in previous question.
  • • Define the constructor.
    • ○ Call the “super” method with an argument.
  • • Define the main method,
    • ○ Create an object for the class “RegularPay”.
    • ○ Call the method with an argument and display the result.
    • ○ Change the input value and again call the method and display the result.

The creation of the abstract class “PayCalculator” is given below:

  • • Declare the “payRate” variable.
  • • Define the constructor.
    • ○ Set the value to the “payRate”.
  • • The “computePay” method is used to return the pay for a given amount of time.
  • • The “changeRate” method is used to set the new value to the pay rate.

 Program:

 Filename: “RegularPay.java”

//definition of "RegularPay" class

public class RegularPay extends PayCalculator

{

    //definition of constructor

    public RegularPay(Double rate)

    {

        //call the "super" method

        super(rate);

    }

    //definition of main method

    public static void main(String[] args)

    {

        //create an object for the class

        RegularPay x = new RegularPay(5...

Explanation of Solution

 Implementation of the derived class “HazardPay”:

The implementation of the derived class “HazardPay” is given below:

  • • The “HazardPay” class is derived from the “PayCalculator” abstract class as discussed in previous question.
  • • Define the constructor.
    • ○ Call the “super” method with an argument.
  • • Override the “computePay” method that returns the amount returned by the base class method multiplied by “1.5”.
  • • Define the main method
    • ○ Create an object for the class “HazardPay”.
    • ○ Call the method with an argument and display the result.
    • ○ Change the input value and again call the method and display the result.

The creation of the abstract class “PayCalculator” is given below:

  • • Declare the “payRate” variable.
  • • Define the constructor.
    • ○ Set the value to the “payRate”.
  • • The “computePay” method is used to return the pay for a given amount of time.
  • • The “changeRate” method is used to set the new value to the pay rate.

 Program:

 Filename: “HazardPay.java”

//definition of "HazardPay" class

public class HazardPay extends PayCalculator

{

    //definition of constructor

    public HazardPay(Double rate)

    {

        //call the "super" method

        super(rate);

    }

    // override the method

    public double computePay(double hours)

    {

        //call the "super" method

        return super.computePay(hours)* 1.5;

    }

    //definition of main method

    public static void main(String[] args)

    {

        //create an object for the class

        HazardPay x = new HazardPay(5...

Blurred answer
Students have asked these similar questions
Objective: The objective of this assignment is to gain practice with pen testing a live web application running on a remote server. The live web application is a known vulnerable web application called DVWA (Damn Vulnerable Web Application) with security settings set to low. The web app is running on an AWS EC2 (Elastic Compute Cloud) instance running Ubuntu 22. Note: The point of this assignment is to step it up a notch, we learnt about different web application vulnerabilities and applied that knowledge, now we are going to pen test and enumerable the vulnerabilities of a web app + the underlying infrastructure it is running on. Before you begin please find out what your IP address is and place it in this sheet so that I can track who is doing what: IP Addresses.docx . Tasks: 1- Start by connecting to the target, I did not install a TLS certificate on purpose that is why you are going to connect via http and not via https: http://3.99.221.134/dvwa/login.php 2- Broken Authentication:…
No AI solutions please
No AI solutions please

Chapter 8 Solutions

Java: An Introduction to Problem Solving and Programming (8th Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY