Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Account { private String name; private int accountNum; private double salary; public Account(String name, int accountNum, double salary) { this.name = name; this.accountNum

public class Account { private String name; private int accountNum; private double salary; public Account(String name, int accountNum, double salary) { this.name = name; this.accountNum = accountNum; this.salary = salary; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAccountNum() { return accountNum; } public void setAccountNum(int accountNum) { this.accountNum = accountNum; } public double getSalary() { return salary; } public void setSalary(double salary) { this.salary = salary; } public static void main(String[] args) { Account[] acts=new Account[5]; double average=0; double total=0; acts[0]=new Account("A", 12345, 25000); acts[1]=new Account("B", 53453, 34000); acts[2]=new Account("C", 34564, 45900); acts[3]=new Account("D", 87898, 10000); acts[4]=new Account("E", 678793, 50000); for (int i = 0; i < acts.length; i++) { total=total+acts[i].getSalary(); } average=total/acts.length; System.out.println("Average salary : "+average); System.out.println("Account having salary more than average salary"); for (int i = 0; i < acts.length; i++) { if(acts[i].getSalary()>average) { System.out.printf("%-20s%-20.2f ", acts[i].getName(), acts[i].getSalary()); } } } }

Q: In Above program Add inheritance and polymorphism

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_2

Step: 3

blur-text-image_3

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 Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

1.what is the significance of Taxonomy ?

Answered: 1 week ago

Question

What are the advantages and disadvantages of leasing ?

Answered: 1 week ago

Question

Name is needed for identifying organisms ?

Answered: 1 week ago