EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 11, Problem 4PE

Explanation of Solution

Program:

File name: “Division.java

//Define an abstract class named Division

public abstract class Division

{

    //Declare required instance variables

    protected String divisionTitle;

    protected int acctNum;

    //Define the Division function

    public Division(String title, int acct)

    {

//Set the company’s division name and the account number

        divisionTitle = title;

        acctNum = acct;

    }

    //Define the function display()

    public abstract void display();

}

File name: “InternationalDivision.java

//Define a class named InternationalDivision

//inheriting the class Division

public class InternationalDivision extends Division

{

    //Declare required instance variables

    protected String country;

    protected String language;

    //Define the overriden method InternationalDivision()

 public InternationalDivision(String title, int acct, String cty, String lang)

    {

        //Call the superclass method

        super(title, acct);

        //Set the country in which the division is located

        //and the language spoken

        country = cty;

        language = lang;

    }

    //Define the function display()

    public void display()

    {

        //Print the result

System.out.println("International Division: " + divisionTitle +

         "  Acct #" + acctNum + "\nLocated in " + country +

         " Language is " + language);

    }

}

File name: “DomesticDivision.java

//Define a class named DomesticDivision

//inheriting the class Division

public class DomesticDivision extends Division

{

    //Declare required instance variable

    protected String state;

    //Define the overriden method DomesticDivision

    public DomesticDivision(String title, int acct, String st)

    {

        //Call the superclass method

        super(title, acct);

        //Set the state in which the division is located

        state = st;

    }

    //Define the function display()

    public void display()

    {

        //Print the result

        System...

Blurred answer
Students have asked these similar questions
Create a subclass of the Employee class from Question 2 named ShiftSupervisor. Add the salary and bonus attributes to it, and override_init_and_str_accordingly. Add the appropriate accessor and mutator methods and check the functionality by prompting a user to input the data for a Shift Supervisor object. Use_str__ to print the result.
This is the question - Create an abstract NewspaperSubscription class with fields for the subscriber name, address, and rate. Include get and set methods for the name field and get methods for the address and subscription rate; the setAddress() method is abstract. Create two subclasses named PhysicalNewspaperSubscription and OnlineNewspaperSubscription. The parameter for the setAddress() method of the PhysicalNewspaperSubscription class must contain at least one digit; otherwise, an error message is displayed and the subscription rate is set to 0. If the address is valid, the subscription rate is assigned $15. The parameter for the setAddress() method of the OnlineNewspaperSubscription class must contain an at sign (@) or an error message is displayed. If the address is valid, the subscription rate is assigned $9. Code I was given - public class DemoSubscriptions {     public static void main(String args[])     {         PhysicalNewspaperSubscription pnsGood = new…
Create an abstract NewspaperSubscription class with fields for the subscriber name, address, and rate. Include get and set methods for the name field and get methods for the address and subscription rate; the setAddress() method is abstract. Create two subclasses named PhysicalNewspaperSubscription and OnlineNewspaperSubscription. The parameter for the setAddress() method of the PhysicalNewspaperSubscription class must contain at least one digit; otherwise, an error message is displayed and the subscription rate is set to 0. If the address is valid, the subscription rate is assigned $15. The parameter for the setAddress() method of the OnlineNewspaperSubscription class must contain an at sign (@) or an error message is displayed. If the address is valid, the subscription rate is assigned $9. Finally, write an application that declares several objects of both subscription subtypes and displays their data fields
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
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
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