import java.util.Scanner;public class BankAccount { int balance; int previousTransaction; String customerName; String customerId; BankAccount(String cname,String cid) { customerName=cname; customerId=cid; } void deposit(int amount) { if(amount !=0) { balance=balance+amount; previousTransaction=amount; } } void withdraw(int amount) { if(amount !=0) { balance=balance-amount; previousTransaction=-amount; } } void PreviousTransaction() { if(previousTransaction>0) { System.out.println("Deposited :"+previousTransaction); } else if(previousTransaction<0) { System.out.println("Withdrawn: "+previousTransaction); } else { System.out.println("No transaction occured"); } } void show() { char option; Scanner scanner = new Scanner(System.in); System.out.println("Welcome "+customerName); System.out.println("Your ID is "+customerId); System.out.println("\n"); System.out.println("A. Check Balance"); System.out.println("B. Deposit"); System.out.println("C. Withdraw"); System.out.println("D. Previous transaction"); System.out.println("E. Exit"); do { System.out.println("==========================================================="); System.out.println("Enter an option"); System.out.println("==========================================================="); option = scanner.next().charAt(0); System.out.println("\n"); switch(option) { case 'A': System.out.println("-------------------------------------------------------"); System.out.println("Balance = "+balance); System.out.println("-------------------------------------------------------"); System.out.println("\n"); break; case 'B': System.out.println("-------------------------------------------------------"); System.out.println("Enter an amount to deposit:"); System.out.println("-------------------------------------------------------"); int amount = scanner.nextInt(); deposit(amount); System.out.println("\n"); break; case 'C' : System.out.println("-------------------------------------------------------"); System.out.println("Enter an amount to withdraw"); System.out.println("-------------------------------------------------------"); int amount2 = scanner.nextInt(); withdraw(amount2); System.out.println("\n"); break; case 'D' : System.out.println("-------------------------------------------------------"); PreviousTransaction(); System.out.println("-------------------------------------------------------"); System.out.println("\n"); break; case 'E': System.out.println("*****************************************************************"); break; default: System.out.println("Invalid Option!!.Please enter again"); break; } }while(option != 'E'); System.out.println("ThankYou for using our services"); }}import java.util.Scanner;public class BankingApplication { public static void main(String args[]) { BankAccount BA = new BankAccount("ArdousGeek","AG001"); BA.show(); }Welcome ArdousGeekYour ID is AG001
A. Check BalanceB. DepositC. WithdrawD. Previous transactionE. Exit===========================================================Enter an option===========================================================A-------------------------------------------------------Balance = 0-------------------------------------------------------
===========================================================Enter an option===========================================================B-------------------------------------------------------Enter an amount to deposit:-------------------------------------------------------50000===========================================================Enter an option===========================================================C-------------------------------------------------------Enter an amount to withdraw-------------------------------------------------------25000===========================================================Enter an option===========================================================D-------------------------------------------------------Withdrawn: -25000-------------------------------------------------------
===========================================================Enter an option===========================================================A-------------------------------------------------------Balance = 25000-------------------------------------------------------
===========================================================Enter an option===========================================================C-------------------------------------------------------Enter an amount to withdraw-------------------------------------------------------5000===========================================================Enter an option===========================================================D-------------------------------------------------------Withdrawn: -5000-------------------------------------------------------
===========================================================Enter an option===========================================================E*****************************************************************ThankYou for using our servicespackage bank;public class Bank { double balance; int numberOfTransaction; double interestRate; double monthlyServiceCharges; public Bank() { } public Bank(double balance, int numberOfTransaction, double interestRate, double monthlyServiceCharges) { this.balance = balance; this.numberOfTransaction = numberOfTransaction; this.interestRate = interestRate; this.monthlyServiceCharges = monthlyServiceCharges; } public double getBalance() { return balance; } public void setBalance(double balance) { this.balance = balance; } public int getnumberOfTransaction() { return numberOfTransaction; } public void setnumberOfTransaction(int numberOfTransaction) { this.numberOfTransaction = numberOfTransaction; } public double getInterestRate() { return interestRate; } public void setInterestrate(double interestrate) { this.interestRate = interestrate; } public double getMonthlyServiceCharges() { return monthlyServiceCharges; } public void setMonthlyServiceCharges(double monthlyServiceCharges) { this.monthlyServiceCharges = monthlyServiceCharges; } void deposit(double amnt) { balance+=amnt; numberOfTransaction++; System.out.println("The Depostited Amount is: "+balance); } void withdraw(double amnt) { if(balance>=amnt) { balance-=amnt; System.out.println("Transaction Succeed"); System.out.println("The Current Balance is: "+balance); numberOfTransaction++; } else { System.out.println("Insufficient Amount..!!"); } } void calcInterest() { double montlyInterest = balance*(interestRate/12); balance+=montlyInterest; //System.out.println("balance is:"+balance); } void montlyProcess() { balance-=monthlyServiceCharges; calcInterest(); // System.out.println("The Balance is:"+balance); setnumberOfTransaction(numberOfTransaction); System.out.println("No Of Transaction:"+numberOfTransaction); setMonthlyServiceCharges(monthlyServiceCharges); System.out.println("Monthly charge:"+monthlyServiceCharges); }}package bank;public class Chequing extends Bank{ boolean status; /* if(balance<25) { System.out.println("Accout is InActive....!!!"+status); } else{ System.out.println("The Accout is Active..."+status); } */ Chequing(double balance,double monthlyServiceCharges,double interestRate) { super();
this.balance = balance; this.interestRate = interestRate; this.monthlyServiceCharges = monthlyServiceCharges; } void updateStatus() { if(balance<25) { System.out.println("Accout is InActive....!!!"); } else { System.out.println("The Accout is Active..."); } } void deposite(double amnt) { super.deposit(amnt); getBalance(); updateStatus(); System.out.println(status); } void withdraw(double amnt) { if(status== true) { System.out.println("You Can not Perform Transaction...!!"); System.out.print(0); } else { super.withdraw(amnt); updateStatus(); } }}package bank;public class BankDemo { public static void main(String[] args) { //System.out.println("------------------------"); //Bank b=new Bank(1000.00,0,3.0,10.00); //b.deposit(200); // b.withdraw(1000); //System.out.println(b.getnumberOfTransaction()); //b.calcInterest(); //b.montlyProcess(); System.out.println("**************"); Chequing c = new Chequing(20000.00, 50.0, 3.0); c.deposite(200); c.withdraw(300); System.out.println(c.getnumberOfTransaction()); }}Output:**************The Depostited Amount is: 20200.0The Accout is Active...falseTransaction SucceedThe Current Balance is: 19900.0The Accout is Active...2
{
int balance;
int previousTransaction;
String customerName;
String customerId;
BankAccount(String cname,String cid)
{
customerName=cname;
customerId=cid;
}
void deposit(int amount)
{
if(amount !=0)
{
balance=balance+amount;
previousTransaction=amount;
}
}
void withdraw(int amount)
{
if(amount !=0)
{
balance=balance-amount;
previousTransaction=-amount;
}
}
void PreviousTransaction()
{
if(previousTransaction>0)
{
System.out.println("Deposited :"+previousTransaction);
}
else if(previousTransaction<0)
{
System.out.println("Withdrawn: "+previousTransaction);
}
else
{
System.out.println("No transaction occured");
}
}
void show()
{
char option;
Scanner scanner = new Scanner(System.in);
System.out.println("Welcome "+customerName);
System.out.println("Your ID is "+customerId);
System.out.println("\n");
System.out.println("A. Check Balance");
System.out.println("B. Deposit");
System.out.println("C. Withdraw");
System.out.println("D. Previous transaction");
System.out.println("E. Exit");
do
{
System.out.println("===========================================================");
System.out.println("Enter an option");
System.out.println("===========================================================");
option = scanner.next().charAt(0);
System.out.println("\n");
switch(option)
{
case 'A':
System.out.println("-------------------------------------------------------");
System.out.println("Balance = "+balance);
System.out.println("-------------------------------------------------------");
System.out.println("\n");
break;
case 'B':
System.out.println("-------------------------------------------------------");
System.out.println("Enter an amount to deposit:");
System.out.println("-------------------------------------------------------");
int amount = scanner.nextInt();
deposit(amount);
System.out.println("\n");
break;
case 'C' :
System.out.println("-------------------------------------------------------");
System.out.println("Enter an amount to withdraw");
System.out.println("-------------------------------------------------------");
int amount2 = scanner.nextInt();
withdraw(amount2);
System.out.println("\n");
break;
case 'D' :
System.out.println("-------------------------------------------------------");
PreviousTransaction();
System.out.println("-------------------------------------------------------");
System.out.println("\n");
break;
case 'E':
System.out.println("*****************************************************************");
break;
default:
System.out.println("Invalid Option!!.Please enter again");
break;
}
}while(option != 'E');
System.out.println("ThankYou for using our services");
}
}
import java.util.Scanner;
public class BankingApplication
{
public static void main(String args[])
{
BankAccount BA = new BankAccount("ArdousGeek","AG001");
BA.show();
}
Welcome ArdousGeek
Your ID is AG001
A. Check Balance
B. Deposit
C. Withdraw
D. Previous transaction
E. Exit
===========================================================
Enter an option
===========================================================
A
-------------------------------------------------------
Balance = 0
-------------------------------------------------------
===========================================================
Enter an option
===========================================================
B
-------------------------------------------------------
Enter an amount to deposit:
-------------------------------------------------------
50000
===========================================================
Enter an option
===========================================================
C
-------------------------------------------------------
Enter an amount to withdraw
-------------------------------------------------------
25000
===========================================================
Enter an option
===========================================================
D
-------------------------------------------------------
Withdrawn: -25000
-------------------------------------------------------
===========================================================
Enter an option
===========================================================
A
-------------------------------------------------------
Balance = 25000
-------------------------------------------------------
===========================================================
Enter an option
===========================================================
C
-------------------------------------------------------
Enter an amount to withdraw
-------------------------------------------------------
5000
===========================================================
Enter an option
===========================================================
D
-------------------------------------------------------
Withdrawn: -5000
-------------------------------------------------------
===========================================================
Enter an option
===========================================================
E
*****************************************************************
ThankYou for using our services
package bank;
public class Bank
{
double balance;
int numberOfTransaction;
double interestRate;
double monthlyServiceCharges;
public Bank()
{
}
public Bank(double balance, int numberOfTransaction, double interestRate, double monthlyServiceCharges)
{
this.balance = balance;
this.numberOfTransaction = numberOfTransaction;
this.interestRate = interestRate;
this.monthlyServiceCharges = monthlyServiceCharges;
}
public double getBalance()
{
return balance;
}
public void setBalance(double balance)
{
this.balance = balance;
}
public int getnumberOfTransaction()
{
return numberOfTransaction;
}
public void setnumberOfTransaction(int numberOfTransaction)
{
this.numberOfTransaction = numberOfTransaction;
}
public double getInterestRate()
{
return interestRate;
}
public void setInterestrate(double interestrate)
{
this.interestRate = interestrate;
}
public double getMonthlyServiceCharges()
{
return monthlyServiceCharges;
}
public void setMonthlyServiceCharges(double monthlyServiceCharges)
{
this.monthlyServiceCharges = monthlyServiceCharges;
}
void deposit(double amnt)
{
balance+=amnt;
numberOfTransaction++;
System.out.println("The Depostited Amount is: "+balance);
}
void withdraw(double amnt)
{
if(balance>=amnt)
{
balance-=amnt;
System.out.println("Transaction Succeed");
System.out.println("The Current Balance is: "+balance);
numberOfTransaction++;
}
else
{
System.out.println("Insufficient Amount..!!");
}
}
void calcInterest()
{
double montlyInterest = balance*(interestRate/12);
balance+=montlyInterest;
//System.out.println("balance is:"+balance);
}
void montlyProcess()
{
balance-=monthlyServiceCharges;
calcInterest();
// System.out.println("The Balance is:"+balance);
setnumberOfTransaction(numberOfTransaction);
System.out.println("No Of Transaction:"+numberOfTransaction);
setMonthlyServiceCharges(monthlyServiceCharges);
System.out.println("Monthly charge:"+monthlyServiceCharges);
}
}
package bank;
public class Chequing extends Bank
{
boolean status;
/*
if(balance<25)
{
System.out.println("Accout is InActive....!!!"+status);
}
else{
System.out.println("The Accout is Active..."+status);
}
*/
Chequing(double balance,double monthlyServiceCharges,double interestRate)
{
super();
this.balance = balance;
this.interestRate = interestRate;
this.monthlyServiceCharges = monthlyServiceCharges;
}
void updateStatus()
{
if(balance<25)
{
System.out.println("Accout is InActive....!!!");
}
else
{
System.out.println("The Accout is Active...");
}
}
void deposite(double amnt)
{
super.deposit(amnt);
getBalance();
updateStatus();
System.out.println(status);
}
void withdraw(double amnt)
{
if(status== true)
{
System.out.println("You Can not Perform Transaction...!!");
System.out.print(0);
}
else
{
super.withdraw(amnt);
updateStatus();
}
}
}
package bank;
public class BankDemo
{
public static void main(String[] args)
{
//System.out.println("------------------------");
//Bank b=new Bank(1000.00,0,3.0,10.00);
//b.deposit(200);
// b.withdraw(1000);
//System.out.println(b.getnumberOfTransaction());
//b.calcInterest();
//b.montlyProcess();
System.out.println("**************");
Chequing c = new Chequing(20000.00, 50.0, 3.0);
c.deposite(200);
c.withdraw(300);
System.out.println(c.getnumberOfTransaction());
}
}
Output:
**************
The Depostited Amount is: 20200.0
The Accout is Active...
false
Transaction Succeed
The Current Balance is: 19900.0
The Accout is Active...
2