Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!