Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer question use Object Oriented Programming in Java. QUESTION 4 Given the following superclass named Advertising and subclasses named Television and SocialMedia. Superclass Advertising Attributes

Answer question use Object Oriented Programming in Java.

image text in transcribedimage text in transcribed

QUESTION 4 Given the following superclass named Advertising and subclasses named Television and SocialMedia. Superclass Advertising Attributes String companyName; Iame of the company to advertise product Methods String product Type; Ile g: book, fashion, facial, etc : normal constructor, mutators, accessors, tostring() abstract double calculateCost(); /to calculate the cost of I/advertising Subclass Attributes : Television :int duration; Ilin seconds Methods String timesloti I/prime or non-prime : : normal constructor, mutators, accessors, toString() abstract method definition Subclass Attributes Social Media Methods String mediaType; //Facebook, Instagram, Twitter : normal constructor, mutators, accessors, toString() abstract method definition a) Write the definition of method calculateCost() for both subclasses that calculate and return the advertising cost using the following information: For television advertisement, the cost will be calculated based on the duration and time slot as shown in Table 1 Table 1: Television advertisement Duration Cost (RM) 5 seconds 125 7 seconds 150 10 seconds 180 The company should pay additional charge RM100 for the prime-time slot advertising. For social media advertisement, the cost that will be charged depends on the social media type as shown in Table 2. Table 2: Social Media advertising Type Cost (RM) Facebook 200 Instagram 180 Twitter 150 (6 marks) b) Write program fragments for the following questions using the polymorphism concept: i. Declare an array of 15 Advertisement objects named advertise, (1 mark) ii. Display the company name and the cost that should be paid by each company that advertise their product on television. (4 marks) iii. Calculate and display the total cost for each social media type. (4 marks)

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions