In java Once you have the above classes create a main method

In java

Once you have the above classes create a main method in the Bank class. Simulate a person arriving to the bank (print the person\'s name, and the bank\'s name), then simulate the person opening an account with initial deposit of $1000. Simulate a deposit of $1000 and a withdrawal of $500. Every time a withdrawal or deposit happens, a receipt is printed with the name, address of the person and his/her current balance.

Solution

// Bank.java
class Bank
{
private static double balance;
private static String personName;
private static String bankName;
private static String address;

public Bank(double amount, String name, String bname, String personAddress)
{
balance = amount;
personName = name;
bankName = bname;
address = personAddress;   
}

public static double getBalance()
{
return balance;
}

public static String getPersonName()
{
return personName;
}

public static String getBankName()
{
return bankName;
}

public static String getAddress()
{
return address;
}


public static void deposit(double amount)
{
balance = balance+amount;

System.out.println(\"\ Deposit Reciept\");
System.out.println(\"Name: \" + personName + \"\ Address: \" + address + \"\ Current Balance: \" + balance + \"\ \");

}

public static void withdraw(double amount)
{
if(amount<balance)
{
balance = balance-amount;
System.out.println(\"Withdrawl Reciept\");
System.out.println(\"Name: \" + personName + \"\ Address: \" + address + \"\ Current Balance: \" + balance + \"\ \");
}
else
{
System.out.println(\"Insufficient funds!!\");
}
}

public static void main(String[] args)
{
Bank bank = new Bank(0,\"John Snow\", \"AXIS Bank\", \"B-108 Wall Street, Frankfurt, USA\");

System.out.println(\"Name: \" + bank.getPersonName());
System.out.println(\"Bank: \" + bank.getBankName());

System.out.println(\"\");

bank.deposit(1000);

bank.withdraw(500);   
}
}

/*
output:

Name: John Snow
Bank: AXIS Bank


Deposit Reciept
Name: John Snow
Address: B-108 Wall Street, Frankfurt, USA
Current Balance: 1000.0

Withdrawl Reciept
Name: John Snow
Address: B-108 Wall Street, Frankfurt, USA
Current Balance: 500.0


*/

In java Once you have the above classes create a main method in the Bank class. Simulate a person arriving to the bank (print the person\'s name, and the bank\'
In java Once you have the above classes create a main method in the Bank class. Simulate a person arriving to the bank (print the person\'s name, and the bank\'

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site