Question: Information for class Chicken and its subclass, Spicy is given below. public class Chicken ( private String chickenType; private int quantity; public final double

Information for class Chicken and its subclass, Spicy is given below. public

class Chicken ( private String chickenType; private int quantity; public final double

Information for class Chicken and its subclass, Spicy is given below. public class Chicken ( private String chickenType; private int quantity; public final double CHICKEN PRICE = 10.00; public Chicken (String chickenType, int quantity) { this.chickenType - chickenType; this.quantity quantity; } public int getQuantity(){ return quantity; public void getChickenType () 1 return chickenType; H public String toString() ( return "Chicken Type: "+chickenType +", Quantity: quantity", "; public class Spicy extends Chicken { private boolean discount Coupon; // if value is true give 5% off public final double ADDON_PRICE 3.10; // add on the price // define normal constructor public boolean isDiscount Coupon () { return discount Coupon; public double calculatePrice () { // calculate the price the customer has to pay } // gives 5% off, if customer has discount coupon. public String toString(){ ( return super.toString() + "Discount Coupon:" discount Coupon; a) Write Java program segments to do the following: i. Define normal constructor for Spicy class. (2 marks) ii. Define the method calculate Price () for Spicy. Price per unit is CHICKEN PRICE plus the ADDON PRICE. 5% discount is given if the customer has a discount coupon. (3 marks) b) In the main method: i. Create an array of objects with type Chicken named chickens. The array size is 100. (1 mark) Assume that 100 Spicy objects have been stored inside the array chickens. Print the quantity and type of chicken for each object. (2 marks) Using the same array, calculate the total price of all the Spicy chickens. (2 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!