sp20bscs0030 Assignment 01
sp20bscs0030 Assignment 01
ID: SP20BSCS0030
Section: BM
import java.util.Scanner;
class Bank{
Scanner s1=new Scanner(System.in);
protected String accountTitle;
protected int accountNumber;
protected float Amount;
protected String accountType;
public Bank(){
}
protected String getaccountTitle(){
return accountTitle;
}
protected int getaccountNumber(){
return accountNumber;
}
protected float getAmount(){
return Amount;
}
protected void setaccountTitle(String accountTitle){
this.accountTitle=accountTitle;
}
protected void setaccountNumber(int accountNumber){
this.accountNumber=accountNumber;
}
protected void setAmount(float Amount){
this.Amount=Amount;
}
protected void Deposit(float Amount){
this.Amount+=Amount;
System.out.println("Amount successfully Deposited");
}
}
class Customer extends Bank {
protected String customerName;
protected String customerEmail;
protected String customerNumber;
public Customer(String customerName,String customerEmail,String customerNumber){
super();
this.customerName=customerName;
this.customerEmail=customerEmail;
this.customerNumber=customerNumber;
}
protected String getcustomerName(){
return customerName;
}
protected String getcustomerEmail(){
return customerEmail;
}
protected String getcustomerNumber(){
return customerNumber;
}
protected void setaccountType(){
System.out.print("Enter Your Account Type: ");
this.accountType=s1.nextLine();
}
protected String getaccountType(){
return this.accountType;
}
}
class currentAccount extends Bank{
public void Withdraw(float Am){
if(this.Amount>0){
if(this.Amount<Am){
System.out.println("Your Account doesn't have enough money");
}
else{
this.Amount-=Am;
System.out.println("Withdraw request successfully completed!");
}
}
else{
System.out.println("Amount can't be negative or zero while processing withdraw
request");
}
}
}
class savingAccount extends Bank{
}
class fixedDepositAccount extends Bank{
}
}
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner s1=new Scanner(System.in);
Bank b1=new Bank();
b1.setaccountNumber(343434);
b1.setaccountTitle("Raja ");
Customer c1=new Customer("Raja","[email protected]","0330220520");
c1.setaccountType();
String Type=c1.getaccountType();
if(Type.equals("Current")){
currentAccount ca=new currentAccount();
ca.Deposit(2000);
ca.Withdraw(5000);
}
else if(Type.equals("Saving")){
savingAccount sa=new savingAccount();
sa.setAmount(5000);
sa.Withdraw(5000);
}
}