Hi everyone,
I have been given an assignment to create a file called FixedStartingBalanceBankAccount. I have also been given a BankAccount class file(attached).
My assignment is to create a BankAccount object in a variable called myFirstAccount with an initial balance of 5000.
After this I have to withdraw 200 from the account and display the balance after withdrawal using JOptionPane messageDialog.
This is the code I have for setting up account with initial balance and making withdrawal. I am not sure if this is the way to do it.
import javax.swing.JOptionPane;
public class FixedStartingBalanceBankAccount
{
public class BankAccount
{
//Constructors
public BankAccount()
{
BankAccount myFirstAccount = new BankAccount();
}
public BankAccount(double initialBalance)
{
initialBalance = 5000;
}
//Methods
public void withdraw(double amount)
{
amount = 200;
}
}
}
If this is correct how do i get the balance and display it using JOptionPane. Any help would be greatly appreciated as i have spent hours upon hours pulling my hair out trying to get this to work.