Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following class: public abstract class Cake1 { protected String name; protected double rate; public Cake1 (String n, double r) { name = n;

Given the following class:

public abstract class Cake1

{ protected String name;

protected double rate;

public Cake1 (String n, double r)

{

name = n;

rate = r; }

public abstract double calcPrice();

public String toString()

{

return String.format(%s %f , name, rate);

}}

  1. Based on class Cake1 and the following table, define TWO (2) subclasses named as orderCake1 and readymadeCake1.

OrderCake1

ReadymadeCake1

Additional attribute

weight(kg)

quantity

Price calculation

rate*weight

rate*quantity

  1. By using classes definition from a), write an application program that will:

i) declare an array of 4 cake objects (both order and readymade); ii) input data for cake objects and store them into the array; iii) display the total price for all types of cakes; iv) display the total price and the quantity sold for readymade cakes;

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

When would you use physical pretotypes and when virtual pretotypes?

Answered: 1 week ago

Question

Example. Evaluate 5n+7 lim 7-00 3n-5

Answered: 1 week ago