Computer Science, asked by dibyendu16, 7 months ago

Write a JAVA program that uses class members and instance members to manipulate different bank accounts. Bank accounts can be of two types. In one type the initial amount is Rs 25000 and in other type the initial amount is Rs 45000. Use a class field to keep count of no. of account opened. Common rate of interest is 8.75% p.a .The interest is to be calculated for one year and then balance is to be updated.

Answers

Answered by MrUnstoppable
0

Let us design a class bankAccount. A bank account has an account number. The bank

gives each account a different, unique number. Each instance of this class maintains one account with an

owner, an account number and current balance.

Normally, the account numbers start with some +ve integer and keep on increasing as the new accounts

are created. We need a way to assign a new account number to each instance as it is created. A new

account can be created by giving the owner’s name and an initial amount.

Nobody should be able to manipulate instance variables directly. Methods must be provided to access (i)

name of the owner (ii) account number (iii) current balance, and (iv) deposit money in the account.

class bankAccount{

private static int nextAccountNumber = 1; //next account number; It must be a static variable

private String person; //the account owner; must be private

private int number; //The account number; must be private

private double balance; //the balance in the account; must be private

Similar questions