Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. 3.Account java
  2. package assignment;
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class Account {
  7. String name;
  8. String accountNumber;
  9. String typeOfAccount;
  10. double amount;
  11. double diposite;
  12. double withdraw;
  13.  
  14. public Account(String name, String accountNumber, String typeOfAccount, double amount) {
  15. this.name = name;
  16. this.accountNumber = accountNumber;
  17. this.typeOfAccount = typeOfAccount;
  18. this.amount = amount;
  19. }
  20.  
  21. double totalAfterDiposite;
  22.  
  23. public double diposite(double diposite) {
  24. this.diposite = diposite;
  25. return totalAfterDiposite = amount + diposite;
  26. }
  27.  
  28. double totalAfterWithdraw;
  29.  
  30. public double withdraw(double withdraw) {
  31. this.withdraw = withdraw;
  32. return totalAfterWithdraw = totalAfterDiposite - withdraw;
  33. }
  34.  
  35. public void Display() {
  36. System.out.println("Name: " + name);
  37. System.out.println("Total Amount After Diposite" + totalAfterDiposite);
  38. System.out.println("Total Amount after Withdraw : " + totalAfterWithdraw);
  39.  
  40. }
  41.  
  42. public static void main(String[] args) {
  43. Scanner scan = new Scanner(System.in);
  44. System.out.println("Enter Name, AccountNumber, TypeOfAccount, Amount");
  45. Account a = new Account(scan.nextLine(), scan.nextLine(), scan.nextLine(), scan.nextDouble());
  46. System.out.println("Enter Diposite amount");
  47. a.diposite(scan.nextDouble());
  48. System.out.println("Enter Withdraw amount");
  49. a.withdraw(scan.nextDouble());
  50. a.Display();
  51.  
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement