Knowee
Questions
Features
Study Tools

Assume that a bank maintains two kinds of account for its customers, one called savings account and the other current account. The savings account provides compound interest and withdrawal facilities but no cheque book facility. The current account provides cheque book facility but no interest. Current account holders should also maintain a minimum balance and if the balance falls below this level, a service charge is imposed.Create a class Account that stores customer name, account number and type of account. From this derive the classes Curr-acct and Sav-acct to make them more specific to their requirements. Include the necessary methods in order to achieve the following tasks:Accept deposit from a customer and update the balance.Display the balance.Compute and deposit interest.Permit withdrawal and update the balance.Check for the minimum balance, impose penalty, if necessary, and update the balance.Write a java program to create a bank account with Name of the account holder, type of account(savings or  current), Account number and Balance amount in the . Also, create 5 customers for the class Bank_account using array of objects. Access the customers to perform credit, debit and display of balance.Input 1:Enter the customers:ReenaSavings1231000RobinCurrent4562000PraveenSavings7893000SherinCurrent2342500DeenaSavings5672000

Question

Assume that a bank maintains two kinds of account for its customers, one called savings account and the other current account. The savings account provides compound interest and withdrawal facilities but no cheque book facility. The current account provides cheque book facility but no interest. Current account holders should also maintain a minimum balance and if the balance falls below this level, a service charge is imposed.Create a class Account that stores customer name, account number and type of account. From this derive the classes Curr-acct and Sav-acct to make them more specific to their requirements. Include the necessary methods in order to achieve the following tasks:Accept deposit from a customer and update the balance.Display the balance.Compute and deposit interest.Permit withdrawal and update the balance.Check for the minimum balance, impose penalty, if necessary, and update the balance.Write a java program to create a bank account with Name of the account holder, type of account(savings or  current), Account number and Balance amount in the . Also, create 5 customers for the class Bank_account using array of objects. Access the customers to perform credit, debit and display of balance.Input 1:Enter the customers:ReenaSavings1231000RobinCurrent4562000PraveenSavings7893000SherinCurrent2342500DeenaSavings5672000

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

Solution

Here is a simple Java program that implements the above requirements:

import java.util.Scanner;

abstract class Account {
    String customerName;
    int accountNumber;
    String accountType;
    double balance;

    Account(String name, int number, String type, double balance) {
        this.customerName = name;
        this.accountNumber = number;
        this.accountType = type;
        this.balance = balance;
    }

    void deposit(double amount) {
        balance += amount;
    }

    void displayBalance() {
        System.out.println("Balance: " + balance);
    }

    abstract void computeInterest();

    abstract void withdraw(double amount);

    abstract void checkMinimumBalance();
}

class Curr_acct extends Account {
    static final double MINIMUM_BALANCE = 1000.0;

    Curr_acct(String name, int number, double balance) {
        super(name, number, "Current", balance);
    }

    void computeInterest() {
        // No interest for current account
    }

    void withdraw(double amount) {
        if (balance - amount >= MINIMUM_BALANCE) {
            balance -= amount;
        } else {
            System.out.println("Insufficient balance");
        }
    }

    void checkMinimumBalance() {
        if (balance < MINIMUM_BALANCE) {
            System.out.println("Service charge imposed");
            balance -= 50; // Assume service charge is 50
        }
    }
}

class Sav_acct extends Account {
    static final double INTEREST_RATE = 0.04; // Assume 4% annual interest

    Sav_acct(String name, int number, double balance) {
        super(name, number, "Savings", balance);
    }

    void computeInterest() {
        balance += balance * INTEREST_RATE;
    }

    void withdraw(double amount) {
        if (balance >= amount) {
            balance -= amount;
        } else {
            System.out.println("Insufficient balance");
        }
    }

    void checkMinimumBalance() {
        // No minimum balance requirement for savings account
    }
}

public class Main {
    public static void main(String[] args) {
        Account[] accounts = new Account[5];
        accounts[0] = new Sav_acct("Reena", 123, 1000);
        accounts[1] = new Curr_acct("Robin", 456, 2000);
        accounts[2] = new Sav_acct("Praveen", 789, 3000);
        accounts[3] = new Curr_acct("Sherin", 234, 2500);
        accounts[4] = new Sav_acct("Deena", 567, 2000);

        // Perform operations
        for (Account account : accounts) {
            account.deposit(500);
            account.displayBalance();
            account.computeInterest();
            account.withdraw(200);
            account.checkMinimumBalance();
            account.displayBalance();
        }
    }
}

This program creates an abstract Account class with common properties and methods, and two derived classes Curr_acct and Sav_acct for current and savings accounts respectively. The Main class creates an array of Account objects and performs operations on them.

This problem has been solved

Similar Questions

Assume that a bank maintains two kinds of accounts for customers, one called as savings account and the other as current account. The saving account provides compound interest (9%) and withdrawal facilities but not cheque book facility. The current account provides cheque book facility but no interest. Current account holders should also maintains a minimum balance of 500 and if the balance falls below this level, a service charge (Rs. 50) is imposed. Create a class Account as abstract that stores customer name, account number and opening balance (Rs. 500). From this derive the classes Current and Saving to make them more specific to their requirements. Include necessary member functions in order to achieve the following tasks:Get the account details using constructor.Display the account details using friend function.Deposit an amount (Rs. 10000) for a customer and update the balanceCompute and deposit interest. Now display the balance using inline function.Withdraw amount (Rs. 10200) for a customer after checking the balance and update the balance.Check for the minimum balance (for current account holders), impose penalty, if necessary, and update the balance.Count the number of transactions carried out using static member variable and display the count value by static member function    OUTPUTAmount deposited successfullyCurrent Balance:10500Interest deposited successfullyCurrent Balance:10695Insufficient balance. Penalty of 50 imposedCustomer Name:JohnAccount Number:123456Current Balance:10695Customer Name:JaneAccount Number:654321Current Balance:450Total number of transactions:3

Write a java program to create a bank account with Name of the account holder, type of account(savings or current), Account number and Balance amount in the account. Also, create 5 customers for the class Bank_account using array of objects. Access the customers to perform credit, debit and display of balance. Input 1: Enter the customers: Reena Savings 123 1000 Robin Current 456 2000 Praveen Savings 789 3000 Sherin Current 234 2500 Deena Savings 567 2000 Enter choice: 1. Credit 2. Debit

Create a SavingsAccount class that behaves just like a BankAccount using inheritanceCreate a SavingsAccount class that behaves just like a BankAccount, but also has an interest rate and a method that increases the balance by the appropriate amount of interest (Hint:use Inheritance).Note: Refer to the displayed test cases for better understanding.Sample Test CasesTest Case 1:Expected Output:account·number:784569874account·holder·name:Raviinitial·balance:50000interest·rate:2Savings·Account·Created:Account·Number:784569874Account·Holder:RaviBalance:50000.0Interest·Rate:2.0%After·adding·interest:Balance:·51000.0Test Case 2:Expected Output:account·number:547981235account·holder·name:Ramanainitial·balance:90000interest·rate:2.5Savings·Account·Created:Account·Number:547981235Account·Holder:RamanaBalance:90000.0Interest·Rate:2.5%After·adding·interest:Balance:·92250.0

Program that creates a class Account that stores a variable balance. The class has methods to startaccount, to deposit money, to withdraw money and tell the current balance amoun

Write a C++ program to implement a class called BankAccount that represents a simple bank account. The class should have private member variables for account number and balance. Include member functions to deposit and withdraw money from the accoun

1/2

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.