Create a Java console banking application FeaturesDeposit De

Create a Java console banking application

FeaturesDeposit

Deposit money into the account

Withdraw

Take money out of the account

Balance

Show the balance of the account

Report

Includes deposits, withdrawals

Exit

Once you exit, all data is gone

No need to save any data

Use Eclipse

The project should be called Assignment1

Apart from the main class, you should have

BankAccount class to deal with the banking logic and storage

Menu class to create and interact with the menu choices

Use encapsulation (getters/setters) for the fields

Comment thoroughly!

No bank logic should be in the main class or Menu class

No menu logic should be in the main class or BankAccount

SAMPLE OUTPUT

Solution

Create file test.java

import java.util.Scanner;
public class test
{
public static void main(String[] args)
{
menu mymenu = new menu();
mymenu.display();
BankAccount myBankAccount = new BankAccount();

while(true)
{
Scanner scanner = new Scanner(System.in);
int choice = scanner.nextInt();   
mymenu.action(myBankAccount,choice);
}


}
}

Create file menu.java

import java.util.Scanner;
public class menu
{

    public menu()
   {

   }
  
   public void display()
   {
System.out.println(\"Please Enter Your choice\");
System.out.println(\"1) Deposit\");   
System.out.println(\"2) Withdraw\");   
System.out.println(\"3) Balance\");   
System.out.println(\"4) Report\");   
System.out.println(\"5) Exit\");       
   }

    public void action( BankAccount acc, int n)
   {
       if( n == 1)
       {
System.out.println(\"Please Enter Deposite amount\");          
Scanner scanner = new Scanner(System.in);
int amm = scanner.nextInt();   
           acc.Deposite(amm);
       }
       else if(n==2)
       {
System.out.println(\"Please Enter Withdraw amount\");          
Scanner scanner = new Scanner(System.in);
int amm = scanner.nextInt();   
           acc.Withdraw(amm);
       }
       else if(n == 3)
       {
           acc.Balance();
       }
       else if(n==4)
       {
           acc.Report();
       }
       else if(n == 5)
       {
System.out.println(\"Goodbye!\");
System.exit(0);
       }
       else
       {
System.out.println(\"Invalid choice\");
       }

   }

}

Create file BankAccount.java

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;

public class BankAccount
{

public double balance;
public Date myarray[] ;
public menu m;
public int entries;
public String Depo_withd[] ;

public BankAccount() {
this.balance = 0;
this.m = new menu();
this.entries = 0;
this.myarray = new Date[1000];
this.Depo_withd = new String[1000];
}

public void Deposite( int amm) {
this.balance = this.balance + amm;
Date now = new Date();
this.myarray[entries] = now;
Depo_withd[entries] = \" + $\" + amm;
entries = entries + 1;
System.out.println(\"Thank you!\");
this.m.display();

}

public void Withdraw( int amm) {
if(this.balance == 0)
{
System.out.println(\"You have no money in the account!\");
this.m.display();   
}
else if(this.balance >= amm)
{
this.balance = this.balance - amm;
System.out.println(\"Take your $\" + amm);
Date now = new Date();
this.myarray[entries] = now;
Depo_withd[entries] = \" - $\" + amm;
entries = entries + 1;
this.m.display();
}
else
{
System.out.println(\"You only have $\" + this.balance +\" in the account\");
this.m.display();   
}
}
public void Balance() {
System.out.println(\"Current balance: $\" + this.balance );   
this.m.display();   
}

public void Report() {
int a = 0;
while(a < this.entries)
{
System.out.println(myarray[a] + Depo_withd[a]);
a = a +1;
}
System.out.println(\"Current balance: $\" + this.balance );   
this.m.display();   
}

}

Sample Output (Run test.java file):

Please Enter Your choice
1) Deposit
2) Withdraw
3) Balance
4) Report
5) Exit
2
Please Enter Withdraw amount
10
You have no money in the account!
Please Enter Your choice
1) Deposit
2) Withdraw
3) Balance
4) Report
5) Exit
1
Please Enter Deposite amount
10
Thank you!
Please Enter Your choice
1) Deposit
2) Withdraw
3) Balance
4) Report
5) Exit
3
Current balance: $10.0
Please Enter Your choice
1) Deposit
2) Withdraw
3) Balance
4) Report
5) Exit
2
Please Enter Withdraw amount
15
You only have $10.0 in the account
Please Enter Your choice
1) Deposit
2) Withdraw
3) Balance
4) Report
5) Exit
2
Please Enter Withdraw amount
5
Take your $5
Please Enter Your choice
1) Deposit
2) Withdraw
3) Balance
4) Report
5) Exit
3
Current balance: $5.0
Please Enter Your choice
1) Deposit
2) Withdraw
3) Balance
4) Report
5) Exit
4
Fri Jan 27 07:40:00 IST 2017 + $10
Fri Jan 27 07:40:30 IST 2017 - $5
Current balance: $5.0
Please Enter Your choice
1) Deposit
2) Withdraw
3) Balance
4) Report
5) Exit
5
Goodbye!

Create a Java console banking application FeaturesDeposit Deposit money into the account Withdraw Take money out of the account Balance Show the balance of the
Create a Java console banking application FeaturesDeposit Deposit money into the account Withdraw Take money out of the account Balance Show the balance of the
Create a Java console banking application FeaturesDeposit Deposit money into the account Withdraw Take money out of the account Balance Show the balance of the
Create a Java console banking application FeaturesDeposit Deposit money into the account Withdraw Take money out of the account Balance Show the balance of the
Create a Java console banking application FeaturesDeposit Deposit money into the account Withdraw Take money out of the account Balance Show the balance of the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site