Hi ALL,
Here I wrote a program for simple bank transaction details in based on the concept of basic OOP syntax (Object Oriented programming) in java.
// Main classpublic class bankApp {
public static void main(String arg[]){
bankAccountMaintance bam=new bankAccountMaintance(1000.00); //initializing values
bam.displayAccountSummary(); //display balance
bam.withdrawal(450.0); //make withdrawal
bam.displayAccountSummary(); // display balance
bam.Deposite(10000.0); // make deposit
bam.displayAccountSummary(); //display balance
}
}
// Sub class
class bankAccountMaintance{
double balance; // account balance
public bankAccountMaintance(double opening_balance){ // constructor
balance=opening_balance;
}
public void Deposite(double de_amt){ // makes deposit
balance +=de_amt;
}
public void withdrawal(double wd_amt){ // makes withdrawal
balance -=wd_amt;
}
public void displayAccountSummary(){ // displays balance
System.out.println(" Balance amount is "+balance);
}
}
OUTPUT
Balance amount is 1000.0
Balance amount is 550.0
Balance amount is 10550.0
No comments:
Post a Comment