Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pkgday3;
- import java.util.Scanner;
- class Q1
- {
- String name;
- int accno;
- int balance;
- String type;
- void account(String n, int ac,int b,String t)
- {
- name=n;
- accno=ac;
- balance=b;
- type=t;
- }
- public int balance(int DEPOSIT,int b)
- {
- balance=b + DEPOSIT;
- return balance;
- }
- int withdrwal(int draw)
- {
- balance=balance-draw;
- return balance;
- }
- void display()
- { System.out.println("the name is : "+name);
- System.out.println("the account is : "+accno);
- System.out.println("the type of account is : "+type);
- System.out.println("the balance is : "+balance);
- }
- }
- class SavingAccount extends Q1
- {
- Scanner sc=new Scanner(System.in);
- public double interest(int n,int r,int t)
- {
- int rest;
- rest= balance *((1+r/n)^(n*t)) ;
- balance=balance+rest;
- return balance;
- }
- }
- class CurrentAccount extends Q1
- {
- Scanner sc=new Scanner(System.in);
- int minimumbal()
- {
- int min=100;
- if(balance < min)
- {
- System.out.println("Enter the days of minimum balance");
- int d=sc.nextInt();
- balance=balance-25*d;
- return balance;
- }
- else
- {
- return balance;
- }
- }
- public int checkbook()
- {
- System.out.println("ENTER THE AMOUNT IN CHEQUE : ");
- int c=sc.nextInt();
- System.out.println("enter 1 for withdrwal || Enter 2 for deposit");
- int a=sc.nextInt();
- if(a==1)
- {
- balance=balance-c;
- }
- if(a==2)
- {
- balance=balance+c;
- }
- return balance;
- }
- }
- class inheritance1
- {
- public static void main(String[] args){
- Scanner sc=new Scanner(System.in);
- System.out.println("Enter the the name of account holder : ");
- String nm=sc.next();
- System.out.println("Enter the account no : ");
- int no=sc.nextInt();
- System.out.println("Enter the balance : ");
- int bal=sc.nextInt();
- System.out.println("Enter the deposit : ");
- int depo=sc.nextInt();
- System.out.println("Enter 1 for Saving account || Enter 2 for Current account : ");
- int b=sc.nextInt();
- if(b==1)
- {
- SavingAccount sa=new SavingAccount();
- sa.account(nm,no,bal," Saving Account");
- sa.balance(depo,bal);
- sa.interest(1,10,2);
- sa.display();
- }
- if(b==2)
- {
- CurrentAccount ca= new CurrentAccount();
- ca.account(nm,no,bal," Cuurent Account");
- ca.balance(depo,bal);
- ca.checkbook();
- ca.minimumbal();
- ca.display();
- sc.close();
- }
- }
- }
Add Comment
Please, Sign In to add comment