Advertisement
Guest User

pakyo

a guest
May 6th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class DebitCard{
  4. private int number;
  5. private String name;
  6. private float amount;
  7.  
  8. public DebitCard(){
  9. this.number = 0;
  10. this.name = "";
  11. this.amount = 0F;
  12. }
  13.  
  14. public DebitCard(int number, String name, float amount){
  15. this.number = number;
  16. this.name = name;
  17. this.amount = amount;
  18. }
  19.  
  20. public int getNumber(){
  21. return number;
  22. }
  23.  
  24. public String getName(){
  25. return name;
  26. }
  27.  
  28. public float getAmount(){
  29. return amount;
  30. }
  31.  
  32. public float interest(float rate){
  33. amount = amount + (amount*(rate/100));
  34. return amount;
  35. }
  36.  
  37. public float swipe(float swipe){
  38. amount = amount - swipe;
  39. return amount;
  40. }
  41.  
  42. public static void main(String[] args){
  43. DebitCard card1 = new DebitCard(123456, "Klydekz", 5000);
  44. Scanner yey = new Scanner(System.in);
  45. float rate = 0;
  46. float swipe = 0;
  47. System.out.println("Debit Card Number: " + card1.getNumber());
  48. System.out.println("Debit Card Name: " + card1.getName());
  49. System.out.println("Debit Card Balance: " + card1.getAmount());
  50. System.out.print("Enter rate of interest[%]: ");
  51. rate = yey.nextFloat();
  52. System.out.println("New balance after interest: " + card1.interest(rate));
  53. System.out.print("Enter the amount you wish to withdraw: ");
  54. swipe = yey.nextFloat();
  55. System.out.println("Your account balance after withdrawal: " + card1.swipe(swipe));
  56. System.out.print("n");
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement