Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program to create a class named Department. In this class, there are three subclasses, namely Production, Accounting, and Marketing, each of

Write a Java program to create a class named Department. In this class, there are three subclasses, namely Production, Accounting, and Marketing, each of which has two member methods named addStaff and displayRevenue. Create these using polymorphism concepts. addStaff method accepts as its input the name of an employee, while the displayRevenue method simply prints the revenue of the department. Use the driver class in Listing 2 to test your program. Listing 2: Departments driver class public class Departments{ /** */ Randomly create the department objects public static Department randomDept() { switch((int)(Math.random()*3)) { case 0: return new Production(); case 1: return new Accounting(); } case 2: return new Marketing(); default: System.out.println("Default"); return new Department(); } public static void main(String args[]) { } Department depts[] = new Department[5]; for(int i=0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Here is the complete Java program that includes the Department class its subclasses Production Accounting Marketing and the Departments driver class t... 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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Create a BPMN diagram of your teams weekly procurement process.

Answered: 1 week ago

Question

3 Find the binary vectors x with 2n-1 dec(x) Answered: 1 week ago

Answered: 1 week ago