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!

Hi socal
You must be a c++ programmer because we dont have methods in Java we have methods.. otherwise i think the problem is that the

public void overdraft(double balance, double minBalance, double fee)

{

if (balance < minBalance)

balance = balance - fee;

else

balance= balance + deposit;

}

does not have the values balance,mini balance and fee passed to them... I will try to run the program latter in the day and get back to you

??

WHy wont something as simple as this compile?

import java.io.*;

public class BankAccount
{
    public String name;
    public int number;
    public double balance;
    public double deposit;

    //constructor
    public BankAccount(String name, int number, double balance)
   {
}
}
public class TestBank
{
	public static void main(String[] args)
	{

		BankAccount b = new BankAccount();
	}
}

says it cant find symbol new

The last thing I posted works when I add void to the constructor, but thats not how its supposed to work.

Also, when I try to add a keyboard.

Scanner keyboard = new keyboard(System.in);

it gives me the same error as when I tried to call a new object from the constructor

HELP!

of course it does. Read that line again, where's your class "keyboard" with a constructor that takes an InputStream?
Most likely what you intended to write was

Scanner keyboard = new Scanner(System.in);

which might work (I never use Scanner, don't know its interface, but I think it works like that).

Ok, but what about my previous post, the one about not being able to create a new BankAccount

BankAccount b = new BankAccount(); it says it cant find the constructor?

Your constructor has a different parameter list from the one you're trying to call.

And for that overdraft method not working....
Its the same problem as is with your constructor. You are NOT passing the correct number of arguments to it.(Madawar actually tried to tell you this only)

Hope it helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.