Guest User

Untitled

a guest
Dec 25th, 2017
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4. public class User {
  5. Scanner secondInput = new Scanner(System.in);
  6. protected String username = "phantomblade";
  7. protected String username1 = "lucario";
  8. protected String password = "shadows";
  9. protected String password1 = "lighting";
  10. protected String bank = "DSK";
  11. protected String notDone = "yes";
  12. protected static String addMoney = "AddMoney";
  13. protected static String pullingMoney = "PullingMoney";
  14. protected static String checkingAccount = "CheckingAccount";
  15.  
  16. protected double account = 1000;
  17.  
  18. protected User(String username, String password) {
  19. this.password = password;
  20. this.username = username;
  21. this.account = 1000;
  22. }
  23.  
  24. public User() {
  25.  
  26. }
  27.  
  28. protected String getPassword() {
  29. return password;
  30. }
  31.  
  32. protected String getUsername() {
  33. return username;
  34. }
  35.  
  36. protected String getAddMoney() {
  37. return addMoney;
  38. }
  39.  
  40. protected String getPullingMoney() {
  41. return pullingMoney;
  42. }
  43.  
  44. protected String getCheckingAccount() {
  45. return checkingAccount;
  46. }
  47.  
  48. public double getAccount() {
  49. return account;
  50. }
  51.  
  52. public String getBank() {
  53. return bank;
  54. }
  55.  
  56. public String getNotDone() {
  57. return notDone;
  58. }
  59.  
  60. public String getUsername1() {
  61. return username1;
  62. }
  63.  
  64. public String getPassword1() {
  65. return password1;
  66. }
  67.  
  68. protected double addMoney(int t) {
  69. double account = 1000;
  70. account += t;
  71. return account;
  72. }
  73.  
  74. protected double pullingMoney(int v) {
  75. double account = 1000;
  76. account -= v;
  77. return account;
  78.  
  79. }
  80.  
  81. protected double checkingAccount() {
  82. return account;
  83. }
  84.  
  85. protected double getResult(double K0, double n, double p) {
  86. return K0 * Math.pow((1 + (p / 100)), n);
  87. }
  88.  
  89. protected int calculatingYear() {
  90. User kris = new User();
  91. int year = 2010;
  92. System.out.println("Please tell us what year did you deposit your money ");
  93. int inputYear = secondInput.nextInt();
  94. int result = 0;
  95. if (inputYear > 2010) {
  96. result = inputYear - year;
  97. System.out.println(
  98. "It seems your money are deposed here more than 1 year so you can get our bank interest rate bonus to your monney :)");
  99.  
  100. System.out.println("Your money have been here for " + result + " years");
  101. System.out.println("Please input the interest rate of the bank");
  102. String interestRate = secondInput.next();
  103. double interestRate1 = Double.parseDouble(interestRate);
  104. System.out.println(interestRate1 + "%");
  105. secondInput.nextLine();
  106.  
  107. System.out.println(
  108. "So the total cash now you have is " + kris.getResult(kris.getAccount(), result, interestRate1));
  109. }
  110. secondInput.close();
  111. return result;
  112. }
  113.  
  114. protected boolean finishing() {
  115. boolean b = true;
  116. ArrayList<String> arrayList = new ArrayList<String>();
  117. Scanner input = new Scanner(System.in);
  118. System.out.println("How much accounts,would you like to check today sir?");
  119. int x = input.nextInt();
  120. User kris = new User();
  121. for (int numberOfAccount1 = 0; numberOfAccount1 <= x; numberOfAccount1++) {
  122. System.out.println("Write your username: ");
  123. String username = input.next();
  124. arrayList.add(username);
  125. System.out.println("Write your password: ");
  126. String password = input.next();
  127. arrayList.add(password);
  128. String str2 = input.next();
  129. System.out.println("Welcome " + username + " to " + str2 + " bank " + " ! ");
  130. }
  131. System.out.println("What would you like to do today with your account? ");
  132.  
  133. String operation = input.next();
  134.  
  135. if (kris.getCheckingAccount().equals(operation)) {
  136. System.out.println(kris.calculatingYear());
  137. }
  138.  
  139. if (kris.getPullingMoney().equals(operation)) {
  140. System.out.println("Ok so you want to pull money,please tell me how much money do you want to take sir");
  141. int v = input.nextInt();
  142. input.nextLine();
  143. System.out.println("You now have " + kris.pullingMoney(v));
  144. }
  145.  
  146. if (kris.getAddMoney().equals(operation)) {
  147. System.out.println("Ok so you want add money,please tell me how much money do you want to add sir");
  148. int t = input.nextInt();
  149. input.nextLine();
  150. System.out.println("You now have left " + kris.addMoney(t));
  151. }
  152. input.close();
  153. return b;
  154. }
  155. }
  156. /*
  157. * @Override public boolean equals(Object arg0) { if (!(arg0 instanceof User))
  158. * return false; User user2 = (User) arg0; if
  159. * (user2.username.equals(this.username) &&
  160. * user2.password.equals(this.password)) { return true; } return false; }
  161. */
Add Comment
Please, Sign In to add comment