fork download
  1. import java.util.Scanner;
  2.  
  3. public class Account_Test
  4. {
  5. public static String transaction;
  6. public static String t_input;
  7.  
  8. //Prepare application to run
  9. public static void main ( String [] args)
  10. {
  11. //Set dummy accounts
  12. Account acc1 = new Account ("Bruce Wayne", 100000000.00);
  13. Account acc2 = new Account ("Clark Kent", 1082.00);
  14. Account acc3 = new Account ("Diana Prince ", 787.00);
  15. Account acc4 = new Account ("Barry Allen", 0.00);
  16. Account acc5 = new Account ("Arthur Curry", 29.00);
  17. Account acc6 = new Account ("Victor Stone", 20000.00);
  18.  
  19. //Display all account balances
  20. System.out.printf("%s balance: $%.2f%n",acc1.GetName(), acc1.GetBalance());
  21. System.out.printf("%s balance: $%.2f%n",acc2.GetName(), acc2.GetBalance());
  22. System.out.printf("%s balance: $%.2f%n",acc3.GetName(), acc3.GetBalance());
  23. System.out.printf("%s balance: $%.2f%n",acc4.GetName(), acc4.GetBalance());
  24. System.out.printf("%s balance: $%.2f%n",acc5.GetName(), acc5.GetBalance());
  25. System.out.printf("%s balance: $%.2f%n",acc6.GetName(), acc6.GetBalance());
  26. t_Prompt();
  27. }
  28.  
  29. public static void t_Prompt()
  30. {
  31. //Initialize scanner to read user input
  32. Scanner inputTransaction = new Scanner (System.in);
  33.  
  34. //Prompt user if transaction is a deposit or withdraw
  35. System.out.printf("Type \"D\" to deposit or, type \"W\" to withdraw. And then press enter :");
  36.  
  37. //put user input into variable
  38. t_input = inputTransaction.next();
  39.  
  40. if (t_input.equals("d")||t_input.equals("D"))
  41. {
  42. d_Prompt();
  43. }
  44. else if (t_input.equals("w")||t_input.equals("w"))
  45. {
  46. w_prompt();
  47. }
  48. else //Exception handle
  49. {
  50. System.out.print("INVALID INPUT. PLEASE TRY AGAIN!\n");
  51. t_Prompt();
  52. }
  53. }
  54.  
  55. public static void d_Prompt()
  56. {
  57. //Prompt deposit amount for account 1
  58. System.out.print("Enter deposit amount for acc1: ");
  59.  
  60. //Initialize scanner to read user input
  61. Scanner inputDeposit = new Scanner (System.in);
  62.  
  63. //Read user input and puts the input into depositAmount variable
  64. double depositAmount = inputDeposit.nextDouble();
  65.  
  66. //Check depositAmount is a positive amount
  67. if(depositAmount > 0)
  68. {
  69. //Using 'deposit method' (in Account.java) to add 'depositAmount'
  70. acc1.deposit(depositAmount);
  71.  
  72. //Displaying depositAmout to account
  73. System.out.printf ("%nAdding %.2f to acc1 balance: %n%n", depositAmount);
  74. }
  75. else
  76. {
  77. System.out.print("INVALID AMOUNT, TRY AGAIN!");
  78. t_Prompt();
  79. }
  80. }
  81.  
  82. public static void w_prompt()
  83. {
  84. //Prompt withdraw amount for account 1
  85. System.out.print("Enter withdraw amount for acc1: ");
  86.  
  87. //Initialize scanner to read user input
  88. Scanner inputWithdraw = new Scanner (System.in);
  89.  
  90. //Read user input and puts the input into depositAmount variable
  91. double withdrawAmount = inputWithdraw.nextDouble();
  92.  
  93. //Displaying depositAmout to account
  94. System.out.printf ("%nWithdrawing %.2f from acc1. Balance: %n%n", withdrawAmount);
  95. }
  96.  
  97.  
  98.  
  99. /*
  100. //Read user input and puts the input into depositAmount variable
  101. double depositAmount = input.nextDouble();
  102.  
  103.  
  104.  
  105.  
  106.  
  107. System.out.print("Enter deposit amount for Account 2: ");
  108.  
  109. //Read user input and puts the input into depositAmount variable
  110. depositAmount = input.nextDouble();
  111.  
  112. //Displaying depositAmout to account
  113. System.out.printf ("%nAdding %.2f to Account 2 balance: %n%n", depositAmount);
  114.  
  115. //
  116. acc2.deposit(depositAmount);
  117.  
  118. System.out.print("Enter deposit amount for Account 3: ");
  119.  
  120. //Read user input and puts the input into depositAmount variable
  121. depositAmount = input.nextDouble();
  122.  
  123. //Displaying depositAmout to account
  124. System.out.printf ("%nAdding %.2f to Account 3 balance: %n%n", depositAmount);
  125.  
  126. //
  127. acc3.deposit(depositAmount);
  128.  
  129. System.out.print("Enter deposit amount for Account 4: ");
  130.  
  131. //Read user input and puts the input into depositAmount variable
  132. depositAmount = input.nextDouble();
  133.  
  134. //Displaying depositAmout to account
  135. System.out.printf ("%nAdding %.2f to Account 4 balance: %n%n", depositAmount);
  136.  
  137. //
  138. acc4.deposit(depositAmount);
  139.  
  140. System.out.print("Enter deposit amount for Account 5: ");
  141.  
  142. //Read user input and puts the input into depositAmount variable
  143. depositAmount = input.nextDouble();
  144.  
  145. //Displaying depositAmout to account
  146. System.out.printf ("%nAdding %.2f to Account 5 balance: %n%n", depositAmount);
  147.  
  148. //
  149. acc5.deposit(depositAmount);
  150.  
  151. System.out.print("Enter deposit amount for Account 6: ");
  152.  
  153. //Read user input and puts the input into depositAmount variable
  154. depositAmount = input.nextDouble();
  155.  
  156. //Displaying depositAmout to account
  157. System.out.printf ("%nAdding %.2f to Account 6 balance: %n%n", depositAmount);
  158.  
  159. //
  160. acc6.deposit(depositAmount);
  161.  
  162. */
  163. //Display all account balances
  164. /* {
  165. System.out.printf("%s balance: $%.2f%n",acc1.GetName(), acc1.GetBalance());
  166. System.out.printf("%s balance: $%.2f%n",acc2.GetName(), acc2.GetBalance());
  167. System.out.printf("%s balance: $%.2f%n",acc3.GetName(), acc3.GetBalance());
  168. System.out.printf("%s balance: $%.2f%n",acc4.GetName(), acc4.GetBalance());
  169. System.out.printf("%s balance: $%.2f%n",acc5.GetName(), acc5.GetBalance());
  170. System.out.printf("%s balance: $%.2f%n",acc6.GetName(), acc6.GetBalance());
  171. }*/
  172.  
  173.  
  174. }
  175.  
  176.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: error: class Account_Test is public, should be declared in a file named Account_Test.java
public class Account_Test
       ^
Main.java:12: error: cannot find symbol
			Account acc1 = new Account ("Bruce Wayne", 100000000.00);
			^
  symbol:   class Account
  location: class Account_Test
Main.java:12: error: cannot find symbol
			Account acc1 = new Account ("Bruce Wayne", 100000000.00);
			                   ^
  symbol:   class Account
  location: class Account_Test
Main.java:13: error: cannot find symbol
			Account acc2 = new Account ("Clark Kent", 1082.00);
			^
  symbol:   class Account
  location: class Account_Test
Main.java:13: error: cannot find symbol
			Account acc2 = new Account ("Clark Kent", 1082.00);
			                   ^
  symbol:   class Account
  location: class Account_Test
Main.java:14: error: cannot find symbol
			Account acc3 = new Account ("Diana Prince ", 787.00);
			^
  symbol:   class Account
  location: class Account_Test
Main.java:14: error: cannot find symbol
			Account acc3 = new Account ("Diana Prince ", 787.00);
			                   ^
  symbol:   class Account
  location: class Account_Test
Main.java:15: error: cannot find symbol
			Account acc4 = new Account ("Barry Allen", 0.00);
			^
  symbol:   class Account
  location: class Account_Test
Main.java:15: error: cannot find symbol
			Account acc4 = new Account ("Barry Allen", 0.00);
			                   ^
  symbol:   class Account
  location: class Account_Test
Main.java:16: error: cannot find symbol
			Account acc5 = new Account ("Arthur Curry", 29.00);
			^
  symbol:   class Account
  location: class Account_Test
Main.java:16: error: cannot find symbol
			Account acc5 = new Account ("Arthur Curry", 29.00);
			                   ^
  symbol:   class Account
  location: class Account_Test
Main.java:17: error: cannot find symbol
			Account acc6 = new Account ("Victor Stone", 20000.00);
			^
  symbol:   class Account
  location: class Account_Test
Main.java:17: error: cannot find symbol
			Account acc6 = new Account ("Victor Stone", 20000.00);
			                   ^
  symbol:   class Account
  location: class Account_Test
Main.java:70: error: cannot find symbol
				acc1.deposit(depositAmount);
				^
  symbol:   variable acc1
  location: class Account_Test
14 errors
stdout
Standard output is empty