Advertisement
Guest User

Untitled

a guest
Mar 11th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. // Daniel Clements
  2.  
  3. import java.util.*;
  4.  
  5. public class Bank
  6. {
  7. public static void main(String args[])
  8. {
  9.  
  10. System.out.print("Please enter your username: ");
  11. Scanner console = new Scanner(System.in);
  12. String user = console.next();
  13.  
  14. int count = 0;
  15. String password = "";
  16.  
  17. do{
  18.  
  19. System.out.print("Please enter your password (must be atleast 8 characters: ");
  20. password = console.next();
  21. count = password.length();
  22.  
  23. if (count < 8)
  24. {
  25. System.out.println("Please enter a longer password");
  26. }
  27.  
  28. }while (count<8);
  29.  
  30. double savings = 5000;
  31. double checking = 1000;
  32.  
  33. for (int i = 4; i>0 ; i--)
  34. {
  35. System.out.println("How may we assist you? \n1. Deposit \n2. Withdrawl \n3. Summary Statement \n4. Exit");
  36. int choice = console.nextInt();
  37. System.out.println("**Your session has " + i + " actions remaining**");
  38.  
  39. switch (choice)
  40. {
  41. case 1:
  42. System.out.println("How much would you like to deposit?");
  43. double amount = console.nextDouble();
  44. System.out.println("In which account? \n1. Checking \n2. Savings");
  45. int choice2 = console.nextInt();
  46. if (choice2 == 1)
  47. {
  48. checking += amount;
  49. System.out.println("Thank you, you now have $" + checking + " in your checking account!");
  50. }
  51. else
  52. {
  53. savings += amount;
  54. System.out.println("Thank you, you now have $" + savings + " in your savings account!");
  55. }
  56. break;
  57.  
  58. case 2:
  59. System.out.println("How much would you like to withdraw?");
  60. double withdraw = console.nextDouble();
  61. System.out.println("From which account? \n1. Checking \n2. Savings");
  62. int choice3 = console.nextInt();
  63. if (choice3 == 1)
  64. {
  65. checking -= withdraw;
  66. System.out.println("Thank you, you now have $" + checking + " in your checking account!");
  67. }
  68. else
  69. {
  70. savings -= withdraw;
  71. System.out.println("Thank you, you now have $" + savings + " in your savings account!");
  72. }
  73. break;
  74.  
  75. case 3:
  76. System.out.println("Summary Statement");
  77. System.out.println("Username: " + user);
  78. System.out.println("Password: " + password.substring(0, password.length() - 4) + "****");
  79. System.out.println("Savings: " + savings);
  80. System.out.println("Checking: " + checking);
  81. break;
  82.  
  83. case 4:
  84. System.out.println("Thank You for Choosing Weston International Bank");
  85. System.out.println("Have a nice day!");
  86.  
  87. System.exit(0);
  88. }
  89. }
  90.  
  91. }
  92.  
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement