public class BankAccount_main
{
public static void main(String[] args)
{
BankAccount_class user;
user = new BankAccount_class("my name here", 2000); // IDE gave error here. idk why
}
class BankAccount_class
{
String Name = null;
int accNo;
int lastAssignNo = 1000;
double accBalance = 0;
final static double percentDividend = 4.0;
double deposit;
double withdrawal;
public BankAccount_class(String a, double d)
{
//initialize instance variables
Name = a;
accNo = lastAssignNo + 1;
accBalance = accBalance + d;
}
public BankAccount_class()
{
//initialize instance variables
Name = null;
accNo = lastAssignNo++;
}
public double Deposit(double a)
{
accBalance = accBalance + a;
return accBalance;
}
public double Withdrawal(double a)
{
if (a >= accBalance)
{
System.out.println("You hace no sufficient balance");
return accBalance;
}
else
{
accBalance = accBalance - a;
return accBalance;
}
}
}
}
so basically, i just want to make sure the input is working. that's why i only made the 'Name' and 'accBalance' parts.
so how can i make this work?
also, can someone explain to me why is there constructor? (why can't we just make method?)
i can't understand how 'static' works lol.
and what's the difference if i put public or private to a variable (or does it called 'instance'?) in a class?
phew. i'm a C++ leaver btw. and it seems Java is more difficult to understand for me.
thanks

New Topic/Question
Reply




MultiQuote








|