import java.util.Scanner;
public class bankAccount
{
//instance variables
public String name;
public int number;
public double balance;
public double deposit;
//constructor
public bankAccount(String name, int number, double balance, double deposit)
{
this.name = name;
this.number = number;
this.balance = balance;
this.deposit = deposit;
}
public double getBalance()
{
return balance;
}
public void getDeposit(double deposit)
{
balance+=deposit;
}
}
public class checkingAccount extends bankAccount
{
//constructor
public checkingAccount(String name, int number, double balance, double deposit, double minBalance, double fee)
{
super(name, number, balance, deposit);
minBalance = 10;
fee = 20;
}
public void overdraft(double balance, double minBalance, double fee)
{
if (balance < minBalance)
balance = balance - fee;
else
balance= balance + deposit;
}
}
import java.util.Scanner;
import java.io.*;
public class testBank
{
public static void main(String[] args)
{
bankAccount b = new bankAccount("john",1,50.00,200);
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter bank name");
String name = keyboard.nextLine();
System.out.println("Enter bank number");
int number = keyboard.nextInt();
System.out.println("Enter bank balance");
double balance = keyboard.nextDouble();
System.out.println("This is ur new info ");
System.out.println(name);
System.out.println(number);
System.out.println(balance);
checkingAccount c = new checkingAccount("bob", 5, 10.0, 22.0, 1.0, 99.0);
System.out.println(overdraft());
}
}
The first class, bankAccount runs ok. However, I cant get the overdraft function to work. help!