Q4. In a restaurant, whenever customers visit, they are provided with items from two categories, one category is fixed for every customer like water bottle, salad and another category is according to the list of items that the customer orders like number of biriyani plates, number of dosas etc. Now, write an abstract class fixed Category having the price of the fixed items as data member and an abstract method complimentaryCost(). Write another derived class orderedCategory which will have price of the food items that the customer has ordered as instance variable and one method ordereditemsCost() which will calculate the cost of ordered items. Also implement the abstract method complimentaryCost() in this derived class to find the cost for complementary items. Assume the customer has ordered each food item only once. Write a java code to display the attributes from each of the classes creating proper instances and invoking the methods from another main class customerCost. Assume price of water bottle is 20, salad 80, biriyani 450, dosa 150. Description fixed Category abstract class. fixed Category abstract class ordered Category derived concrete class ordered Category derived concrete class ordered Category derived concrete class customerCost is a public class where main function/method is written Description Variables double bottle_price, salad_price, complimentaryCost() is abstract method complimentaryCost() is abstract method Variable biriyani_price, dosa_price ordered ItemsCost() is a concrete method which will add the cost of the food items Give definition for the abstract method complimentaryCost()which will add the cost of the food items Sample Input Bottle_price=20, Salad_price-80 biriyani_price=450, dosa_price=150 Sample Output cost of order is 600 cost for complementary items is 100

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Q4. In a restaurant, whenever customers visit, they are provided with items from two categories, one category is fixed for every customer like water bottle, salad and another category is according to the list
of items that the customer orders like number of biriyani plates, number of dosas etc.
Now, write an abstract class fixed Category having the price of the fixed items as data member and an abstract method complimentaryCost().
Write another derived class ordered Category which will have price of the food items that the customer has ordered as instance variable and one method ordered itemsCost() which will calculate the cost of
ordered items. Also implement the abstract method complimentaryCost() in this derived class to find the cost for complementary items. Assume the customer has ordered each food item only once.
Write a java code to display the attributes from each of the classes creating proper instances and invoking the methods from another main class customerCost. Assume price of water bottle is 20, salad 80,
biriyani 450, dosa 150.
Description
fixed Category abstract class
fixed Category abstract class
ordered Category derived concrete class
ordered Category derived concrete class
ordered Category derived concrete class
customer Cost is a public class where main
function/method is written
Description
Variables double bottle_price, salad_price,
complimentaryCost() is abstract method
complimentaryCost() is abstract method
Variable biriyani_price, dosa_price
ordered Items Cost() is a concrete method which
will add the cost of the food items
Give definition for the abstract method
complimentaryCost()which will add the cost of the
food items
Sample Input
Bottle_price=20,
Salad_price-80
biriyani_price=450,
dosa_price=150
Sample Output
cost of ordered items is 600
cost for complementary items is 100
Transcribed Image Text:Q4. In a restaurant, whenever customers visit, they are provided with items from two categories, one category is fixed for every customer like water bottle, salad and another category is according to the list of items that the customer orders like number of biriyani plates, number of dosas etc. Now, write an abstract class fixed Category having the price of the fixed items as data member and an abstract method complimentaryCost(). Write another derived class ordered Category which will have price of the food items that the customer has ordered as instance variable and one method ordered itemsCost() which will calculate the cost of ordered items. Also implement the abstract method complimentaryCost() in this derived class to find the cost for complementary items. Assume the customer has ordered each food item only once. Write a java code to display the attributes from each of the classes creating proper instances and invoking the methods from another main class customerCost. Assume price of water bottle is 20, salad 80, biriyani 450, dosa 150. Description fixed Category abstract class fixed Category abstract class ordered Category derived concrete class ordered Category derived concrete class ordered Category derived concrete class customer Cost is a public class where main function/method is written Description Variables double bottle_price, salad_price, complimentaryCost() is abstract method complimentaryCost() is abstract method Variable biriyani_price, dosa_price ordered Items Cost() is a concrete method which will add the cost of the food items Give definition for the abstract method complimentaryCost()which will add the cost of the food items Sample Input Bottle_price=20, Salad_price-80 biriyani_price=450, dosa_price=150 Sample Output cost of ordered items is 600 cost for complementary items is 100
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Developing computer interface
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education