Question
Hello I hava a bank System project and there is some errors in the code and I want to you to fix it please ,and
Hello
I hava a bank System project and there is some errors in the code and I want to you to fix it please ,and make main method . in addition i want to add this (According to user type, show all possible operations 1. Deposit 2. Withdraw 3. Balance 4. Transfer 5. Return to main menu Enter Your Choice:) . this run sample to show how the cod should work.
Run sample run: Welcome to THE BANK WEBSITE 1 :
Open a new account 2:
Exit ----------
Enter Your Choice-----------
1 -----------
Enter Account Type ------------- -----------
1: Open Normal Account ------------- -----------
2: Controlled Account ------------- -----------
3: Restricted account -------------
1 ----------- Enter Operation type ------------- -----------
1: Deposit ------------- -----------
2: Witdraw ------------- -----------
3: Balance ------------- -----------
4: Transfer ------------- -----------
5: Main Menu -------------
1 Enter amount 2500 -----------
Enter Operation type ------------- -----------
1: Deposit ------------- -----------
2: Witdraw ------------- -----------
3: Balance ------------- -----------
4: transfer ------------- -----------
5: Main Menu -------------
3 balance is :2500.0 -----------
Enter Operation type ------------- ----------- 1
: Deposit ------------- ----------- 2:
Witdraw ------------- -----------
3: Balance ------------- -----------
4: transfer ------------- -----------
5: Main Menu -------------
2 Enter amount 1000 -----------
Enter Operation type ------------- -----------
1: Deposit ------------- -----------
2: Witdraw ------------- -----------
3: Balance ------------- -----------
4: transfer ------------- -----------
5: Main Menu -------------
3 balance is :1500.0 -----------
Enter Operation type ------------- -----------
1: Deposit ------------- -----------
2: Witdraw ------------- -----------
3: Balance ------------- -----------
4: transfer ------------- -----------
5: Main Menu -------------
1 Enter amount 3500 -----------
Enter Operation type ------------- -----------
1: Deposit ------------- -----------
2: Witdraw ------------- -----------
3: Balance ------------- -----------
4: transfer ------------- -----------
5: Main Menu -------------
3 balance is :5000.0 -----------
Enter Operation type ------------- -----------
1: Deposit ------------- -----------
2: Witdraw ------------- -----------
3: Balance ------------- -----------
4: transfer ------------- -----------
5: Main Menu -------------
4 Enter amount 20000 There is no enough balance! -----------
Enter Operation type ------------- -----------
1: Deposit ------------- -----------
2: Witdraw ------------- -----------
3: Balance ------------- -----------
4: transfer ------------- -----------
5: Main Menu -------------
5 Welcome to THE BANK WEBSITE
1 : Open a new account
2: Exit ----------
Enter Your Choice-----------
2 BUILD SUCCESSFUL (total time: 1 minute 16 seconds)
THIS THE COD IN JAVA language :
import java.util.Scanner ;
abstract class User { double balance;
abstract void withdraw(double amount);
User(double balance) { this.balance = balance; } }
// Interface FreeDepositAndInquiry that contains methods deposit, transfer, and getBalance interface FreeDepositAndInquiry { void deposit(double amount); void transfer(double amount); double getBalance(); }
// Interface LimitedDeposit that contains method deposit interface LimitedDeposit { void deposit(double amount); }
// Class NormalAccount that extends User and implements FreeDepositAndInquiry class NormalAccount extends User implements FreeDepositAndInquiry { NormalAccount(double balance) { super(balance); }
@Override public void deposit(double amount) { // Increase the balance by the deposit amount balance += amount; }
public void transfer(double amount) { // Decrease the balance by the transfer amount if sufficient balance if (balance >= amount) { balance -= amount; } else { System.out.println("Insufficient balance"); } }
public double getBalance() { // Return the current balance return balance; }
public void withdraw(double amount) { // Decrease the balance by the withdrawal amount if sufficient balance if (balance >= amount) { balance -= amount; } else { System.out.println("Insufficient balance"); } } }
// Class ControlledAccount that extends User and implements LimitedDeposit class ControlledAccount extends User implements LimitedDeposit { ControlledAccount(double balance) { super(balance); }
public void deposit(double amount) { // Increase the balance by the deposit amount balance += amount; }
public void withdraw(double amount) { // Decrease the balance by the withdrawal amount if sufficient balance and within the daily limit if (balance >= amount && amount <= 2000) { balance -= amount; } else { System.out.println("Withdrawal limit exceeded or Insufficient balance"); } } }
// Class RestrictedAccount that extends User class RestrictedAccount extends User { RestrictedAccount(double balance) { super(balance); }
public void withdraw(double amount) { // Decrease the balance by the withdrawal amount if sufficient balance and within the daily limit if (balance >= amount && amount <= 500) { balance -= amount; } else { System.out.println("Withdrawal limit exceeded or Insufficient balance"); } }
}
class BankWebsite {
private static Object a; public static void main(String[] args) { Scanner a= new Scanner (System.in); int choice; do { System.out.println("Welcome to the bank website"); System.out.println("1. Create account"); System.out.println("2. Exit from website"); System.out.print("Enter your choice: "); choice = a.nextInt(); if (choice == 1) { createAccount(); } } while (choice != 2);
private static void createAccount() { System.out.println("Enter user name: "); String name = a.next(); System.out.println("Enter user PIN: "); int pin = a.nextInt(); System.out.println("Enter account type (1. Normal 2. Controlled 3. Restricted): "); int type = a.nextInt(); User user; } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started