import java.io.*;
class Account
{
String name;
int acc_no;
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
void accept()
{
try
{
System.out.print("Enter the Name : ");
name = br.readLine();
System.out.print("Enter the Account No. : ");
acc_no = Integer.parseInt(br.readLine());
}
catch(Exception e ) { }
}
void display()
{
System.out.println("Customer Name : "+name);
System.out.println("Account No. : "+acc_no);
}
};
class SavingAcc extends Account
{
final double min_bal = 500;
double saving_bal=500;
};
class AccDetails extends SavingAcc
{
double amount;
void deposit()
{
try
{
System.out.print("\nEnter the Amount : ");
amount = Double.parseDouble(br.readLine());
saving_bal = saving_bal + amount;
System.out.println("Amount Deposited Successfully.\n");
}
catch(Exception e ) { }
}
void withdraw()
{
try
{
System.out.print("\nEnter the Amount : ");
amount = Double.parseDouble(br.readLine());
if( amount > (saving_bal - min_bal) )
{
System.out.println("Transaction Not Possible!\n");
}
else
{
saving_bal = saving_bal - amount;
System.out.println("Withdrawl Transaction Successful.\n");
}
}
catch(Exception e ) { }
}
void display()
{
System.out.println("\n=========> Account Details <=========");
super.display();
System.out.println("Minimum Balance : "+min_bal);
System.out.println("Saving Balance : "+saving_bal);
System.out.println("=====================================\n");
}
};
class Exp9_2
{
public static void main(String[] args)
{
AccDetails a = new AccDetails();
a.accept();
int ch=0;
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
while(ch!=4)
{
try
{
System.out.println("1. Deposit");
System.out.println("2. Withdraw");
System.out.println("3. Display");
System.out.println("4. Exit");
System.out.print("Enter Your Choice... ");
ch = Integer.parseInt(br.readLine());
switch(ch)
{
case 1:
{
a.deposit();
break;
}
case 2:
{
a.withdraw();
break;
}
case 3:
{
a.display();
break;
}
case 4:
{
break;
}
}
}
catch(Exception e) { }
}
}
}
No comments:
Post a Comment