Advertisement
Naimul_X

Untitled

Aug 23rd, 2020
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. ________________________________**********************MRITTIKA ASSIGNMENT JAVA************************___________
  2.  
  3.  
  4.  
  5. package bankaccount;
  6.  
  7.  
  8. public class Test {
  9. public static void main(String[] args) {
  10. Account gates_account=new Account("BILL GATES","1214",500);
  11. Account jobs_account=new Account("STEVE JOBS","15000",1000);
  12.  
  13. gates_account.display();
  14. System.out.println("NAME: "+gates_account.name);
  15. System.out.println("ACC NO: "+gates_account.acc_no);
  16. System.out.println("BALANCE: "+gates_account.balance);
  17. gates_account.deposit(1000);
  18. gates_account.display();
  19. System.out.println("AFTER DEPOSIT: "+gates_account.balance);
  20.  
  21. gates_account.withdraw(850);
  22. System.out.println("AFTER WITHDRAW: "+gates_account.balance);
  23. gates_account.display();
  24.  
  25.  
  26. }
  27. }
  28.  
  29. ****************************************************************************************
  30.  
  31.  
  32.  
  33. package bankaccount;
  34.  
  35.  
  36. public class Account {
  37. String name;
  38. String acc_no;
  39. double balance;
  40.  
  41. Account(String name,String acc_no,double balance)
  42. {
  43. this.name=name;
  44. this.acc_no=acc_no;
  45. this.balance=balance;
  46.  
  47. }
  48.  
  49. public double deposit(double ammount)
  50. {
  51. this.balance+=ammount;
  52.  
  53. return this.balance;
  54. }
  55. public double withdraw(double ammount)
  56. {
  57. this.balance-=ammount;
  58.  
  59. return this.balance;
  60. }
  61.  
  62. public void display()
  63. {
  64. System.out.println("CURRENT BALANCE: "+balance);
  65. }
  66.  
  67.  
  68. }
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement