Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I have a bank project that make the user enter the user name and the pin also he can Login with his account the

Hello

I have a bank project that make the user enter the user name and the pin also he can Login with his account the first option in the program make you choice off two option ((Welcome to THE BANK WEBSITE 1 : Open a new account 2: Exit )) then if he choice to open a new a account the user will have choice between three account ((Enter Account Type 1: Open Normal Account 2: Controlled Account 3: Restricted account)). Third , the user will chose one of the 5 options(( Enter Operation type 1: Deposit 2: Withdraw 3: Balance 4: Transfer 5: Main Menu)) . To be in notice that should also be (main) number and a personal identification number (PIN). In this simulation, the user will need to type the PIN as identifier. There are three types of users: User has an open normal account: can withdraw and deposit any amount of money; and can inquire about the balance User has a controlled account: can withdraw maximum 2000 SR per day and deposit any amount of money User has a restricted account: can withdraw maximum 500 SR per day and deposit any amount of money.

This is the cod and this cod without pin in java language and please fix it :

import java.util.Scanner;

abstract class User {

double balance;

abstract void withdraw(double amount);

User(double balance) {

this.balance = balance;

}

}

interface FreeDepositAndInquiry {

void deposit(double amount);

void transfer(double amount);

double getBalance();

}

interface LimitedDeposit {

void deposit(double amount);

}

class NormalAccount extends User implements FreeDepositAndInquiry {

NormalAccount(double balance) {

super(balance);

}

@Override

public void deposit(double amount) {

balance += amount;

}

public void transfer(double amount) {

if (balance >= amount) {

balance -= amount;

} else {

System.out.println("Insufficient balance");

}

}

public double getBalance() {

return balance;

}

public void withdraw(double amount) {

if (balance >= amount) {

balance -= amount;

} else {

System.out.println("Insufficient balance");

}

}

}

class ControlledAccount extends User implements LimitedDeposit {

ControlledAccount(double balance) {

super(balance);

}

public void deposit(double amount) {

balance += amount;

}

public void withdraw(double amount) {

if (balance >= amount && amount <= 2000) {

balance -= amount;

} else {

System.out.println("Withdrawal not allowed");

}

}

}

class RestrictedAccount extends User {

RestrictedAccount(double balance) {

super(balance);

}

public void withdraw(double amount) {

System.out.println("Withdrawal not allowed");

}

}

public class BankSystem {

static Scanner input = new Scanner(System.in);

static User user;

public static void main(String[] args) {

System.out.println("Welcome to THE BANK WEBSITE");

System.out.println("1 : Open a new account");

System.out.println("2: Exit");

System.out.print("Enter Your Choice: ");

int choice = input.nextInt();

while (choice != 2) {

if (choice == 1) {

System.out.println("Enter Account Type");

System.out.println("1: Open Normal Account");

System.out.println("2: Controlled Account");

System.out.println("3: Restricted account");

int accountType = input.nextInt();

System.out.print("Enter Initial Balance: ");

double balance = input.nextDouble();

switch (accountType) {

case 1:

user = new NormalAccount(balance);

break;

case 2:

user = new ControlledAccount(balance);

break;

case 3:

user = new RestrictedAccount(balance);

break;

default:

System.out.println("Invalid Account Type");

break;

}

}

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxxviii Special Issue On Database And Expert Systems Applications Lncs 11250

Authors: Abdelkader Hameurlain ,Roland Wagner ,Sven Hartmann ,Hui Ma

1st Edition

3662583836, 978-3662583838

More Books

Students also viewed these Databases questions