Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Chapter 10 Exercise 7 Pizza.java, DeliveryPizza.java and DemoPizzas.java Make a class named Pizza with the following data fields: description - of type String price -

Chapter 10 Exercise 7 Pizza.java, DeliveryPizza.java and DemoPizzas.java

Make a class named Pizza with the following data fields:

description - of type String

price - of type double

The description stores the type of pizza (such as sausage and onion). Include a constructor that requires arguments for both fields and a method named display to display the data. For example, if the description is 'sausage and onion' and the price is '14.99', the display method should output:

sausage and onion pizza Price: $14.99

make a subclass named DeliveryPizza that inherits from Pizza but adds the following data fields:

deliveryFee - of type double

address - of type String

The description, price, and delivery address are required as arguments to the constructor. The delivery fee is $3 if the pizza ordered costs more than $15; otherwise it is $5.

public class DeliveryPizza

{

// Define DeliveryPizza class here

}

public class DemoPizzas

{

public static void main(String args[])

{

// Write demo program here

}

}

public class Pizza

{

// Define the Pizza class here

}

Question 2

Chapter 11 Complete Exercise 4 Division.java, InternationalDivision.java, DomesticDivision.java and UseDivision.java

make an abstract Division class with fields for a company's division name and account number, and an abstract display() method. Use a constructor in the superclass that requires values for both fields. Create two subclasses named InternationalDivision and DomesticDivision. The InternationalDivision includes a field for the country in which the division is located and a field for the language spoken; its constructor requires both. The DomesticDivision includes a field for the state in which the division is located; a value for this field is required by the constructor.

public abstract class Division

{

protected String divisionTitle;

protected int acctNum;

public Division(String title, int acct)

{

//put code here

}

public abstract void display();

}

public class DomesticDivision extends Division

{

protected String state;

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

{

// put code here

}

public void display()

{

// put code here

}

}

public class InternationalDivision extends Division

{

protected String country;

protected String language;

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

{

// put code here

}

public void display()

{

// put code here

}

}

public abstract class UseDivision

{

public static void main(String[] args)

{

DomesticDivision abcDomDiv = new

DomesticDivision("Sales", 123, "California");

DomesticDivision xyzDomDiv = new

DomesticDivision("Technology", 234, "Kansas");

InternationalDivision abcIntDiv = new

InternationalDivision("Technology", 345, "Germany", "German");

InternationalDivision xyzIntDiv = new

InternationalDivision("Marketing", 456, "Japan",

"Japanese");

abcDomDiv.display();

xyzDomDiv.display();

abcIntDiv.display();

xyzIntDiv.display();

}

}

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

Step: 3

blur-text-image

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions