Knowee
Questions
Features
Study Tools

Create an abstract class Bank with an abstract method getRateOfInterest();    In class SBI calculate the interest amount as 5% of the principal by overriding the method getRateOfInterest(); and display. In the class PNB  calculate the interest amount as 6% of the principal by overriding the method getRateOfInterest(); and display

Question

Create an abstract class Bank with an abstract method getRateOfInterest();    In class SBI calculate the interest amount as 5% of the principal by overriding the method getRateOfInterest(); and display. In the class PNB  calculate the interest amount as 6% of the principal by overriding the method getRateOfInterest(); and display

🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a step-by-step guide on how to create the abstract class Bank with the abstract method getRateOfInterest() and the classes SBI and PNB that override this method:

Step 1: Create the abstract class Bank

public abstract class Bank {
    abstract double getRateOfInterest();
}

Step 2: Create the class SBI that extends Bank and overrides the method getRateOfInterest()

public class SBI extends Bank {
    double principal = 10000; // assuming a principal amount

    double getRateOfInterest() {
        return (principal * 5) / 100; // calculating 5% of principal
    }

    void display() {
        System.out.println("Interest amount in SBI: " + getRateOfInterest());
    }
}

Step 3: Create the class PNB that extends Bank and overrides the method getRateOfInterest()

public class PNB extends Bank {
    double principal = 10000; // assuming a principal amount

    double getRateOfInterest() {
        return (principal * 6) / 100; // calculating 6% of principal
    }

    void display() {
        System.out.println("Interest amount in PNB: " + getRateOfInterest());
    }
}

Step 4: Create a main class to test the SBI and PNB classes

public class Main {
    public static void main(String[] args) {
        SBI sbi = new SBI();
        sbi.display();

        PNB pnb = new PNB();
        pnb.display();
    }
}

When you run the Main class, it will display the interest amount for SBI and PNB.

This problem has been solved

Similar Questions

Write a java program to perform the concept of method overriding for calculating simple interest of 3 banks A,B,C., Bank A’s rate of interest-10%, Bank’s B rate of interest-9%, Bank’C rate of interest -7%.

1) Rajiv deposited Rs.10,000 into a savings account that offers a simple interest rate of 6% per year. Ifhe keeps the money in the account for 3 years:a. Write the formula for finding the simple interest when the principal (P), rate (R), and time (T) aregiven.b. Calculate the total interest earned by Rajiv.c. Find the final amount in his savings account after the interest is added

All the banks operating in India are controlled by RBI. RBI has set a well defined guideline (e.g. minimum interest rate, minimum balance allowed, maximum withdrawal limit etc) which all banks must follow. For example, suppose RBI has set minimum interest rate applicable to a saving bank account to be 4% annually; however, banks are free to use 4% interest rate or to set any rates above it.Write a program to implement bank functionality in the above scenario. Note: Create few classes namely Customer, Account, RBI (Base Class) and few derived classes (SBI, ICICI, PNB etc). Assume and implement required member variables and functions in each class using inheritance concept by c++

Show all the formulae and steps of the calculations. If you are using acalculator, show all the calculator inputs. You are required to round offthe final answer only, to two (2) decimal places, e.g., 56.837 = 56.84.• Please do not round off the answers of the calculations before the finalanswer. No marks will be awarded if you round off intermediate workingsbefore the final answer.2.1 You have a lump sum of R500 000 to invest. The bank offers you aninterest rate of 6% per annum.2.1.1 Calculate how much you will receive after five (5) years ifinterest is compounded weekly

Mr. Agarwal invests certain sum at 5% per annum compound interest for three years. Write a program in Java to calculate: (a) the interest for the first year (b) the interest for the second year (c) the amount after three years. Take sum as an input from the user. Sample Input: Principal = ₹5000, Rate =10%, Time = 3 yrs Sample Output: Interest for the first year: ₹500 Interest for the second year: ₹550 Interest for the third year: ₹605

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.