Guest User

Untitled

a guest
Jun 24th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. package pkgday3;
  2. import java.util.Scanner;
  3. class Q1
  4. {
  5. String name;
  6. int accno;
  7. int balance;
  8. String type;
  9. void account(String n, int ac,int b,String t)
  10. {
  11. name=n;
  12. accno=ac;
  13. balance=b;
  14. type=t;
  15.  
  16. }
  17. public int balance(int DEPOSIT,int b)
  18. {
  19. balance=b + DEPOSIT;
  20. return balance;
  21. }
  22. int withdrwal(int draw)
  23. {
  24. balance=balance-draw;
  25. return balance;
  26. }
  27. void display()
  28. { System.out.println("the name is : "+name);
  29. System.out.println("the account is : "+accno);
  30. System.out.println("the type of account is : "+type);
  31. System.out.println("the balance is : "+balance);
  32. }
  33. }
  34. class SavingAccount extends Q1
  35. {
  36. Scanner sc=new Scanner(System.in);
  37. public double interest(int n,int r,int t)
  38. {
  39. int rest;
  40. rest= balance *((1+r/n)^(n*t)) ;
  41. balance=balance+rest;
  42. return balance;
  43. }
  44. }
  45. class CurrentAccount extends Q1
  46. {
  47. Scanner sc=new Scanner(System.in);
  48. int minimumbal()
  49. {
  50. int min=100;
  51. if(balance < min)
  52. {
  53. System.out.println("Enter the days of minimum balance");
  54. int d=sc.nextInt();
  55. balance=balance-25*d;
  56. return balance;
  57. }
  58. else
  59. {
  60. return balance;
  61. }
  62. }
  63. public int checkbook()
  64. {
  65. System.out.println("ENTER THE AMOUNT IN CHEQUE : ");
  66. int c=sc.nextInt();
  67. System.out.println("enter 1 for withdrwal || Enter 2 for deposit");
  68. int a=sc.nextInt();
  69. if(a==1)
  70. {
  71. balance=balance-c;
  72. }
  73. if(a==2)
  74. {
  75. balance=balance+c;
  76. }
  77. return balance;
  78. }
  79.  
  80. }
  81. class inheritance1
  82. {
  83. public static void main(String[] args){
  84. Scanner sc=new Scanner(System.in);
  85. System.out.println("Enter the the name of account holder : ");
  86. String nm=sc.next();
  87. System.out.println("Enter the account no : ");
  88. int no=sc.nextInt();
  89. System.out.println("Enter the balance : ");
  90. int bal=sc.nextInt();
  91. System.out.println("Enter the deposit : ");
  92. int depo=sc.nextInt();
  93. System.out.println("Enter 1 for Saving account || Enter 2 for Current account : ");
  94. int b=sc.nextInt();
  95. if(b==1)
  96. {
  97. SavingAccount sa=new SavingAccount();
  98. sa.account(nm,no,bal," Saving Account");
  99. sa.balance(depo,bal);
  100.  
  101. sa.interest(1,10,2);
  102. sa.display();
  103. }
  104. if(b==2)
  105. {
  106. CurrentAccount ca= new CurrentAccount();
  107. ca.account(nm,no,bal," Cuurent Account");
  108. ca.balance(depo,bal);
  109. ca.checkbook();
  110. ca.minimumbal();
  111. ca.display();
  112. sc.close();
  113. }
  114. }
  115. }
Add Comment
Please, Sign In to add comment