Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I want a bank project that make the user enter the user name and the pin also he can Login the first option in

Hello

I want a bank project that make the user enter the user name and the pin also he can Login 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)). 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 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). Please I want the cod for this thank you.

This is the cod that I tried to fix it but the option for the account (balance , deposit ,withdraw,..) is not coming and is not working :

import java.util.Scanner;

abstract class User {

double balance;

int pin;

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;

}

@Override

public void withdraw(double amount) {

if (balance >= amount) {

balance -= amount;

} else {

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

} if else {

System.out.println("Incorrect PIN");

}

}

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);

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.print("Enter your username: ");

String use = input.nextLine();

System.out.print("Enter your PIN: ");

int pin = input.nextInt();

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

Power Bi And Azure Integrating Cloud Analytics For Scalable Solutions

Authors: Kiet Huynh

1st Edition

B0CMHKB85L, 979-8868959943

More Books

Students also viewed these Databases questions

Question

How would we like to see ourselves?

Answered: 1 week ago