Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can someone fill in the blanks in write your code part? import java.util. * ; import java.util.stream. * ; import static java.util.stream.Collectors.toList; class Account {
Can someone fill in the blanks in write your code part?
import java.util.;
import java.util.stream.;
import static java.util.stream.Collectors.toList;
class Account
public long accountNumber;
public String holderName;
public double balance;
Create constructor to initialize the class with the params above
public Accountlong accountNumber, String holderName, double balance
this.accountNumber accountNumber;
this.holderName holderName;
this.balance balance;
interface IBankingSystem
void createAccountAccount account;
void updateAccountNamelong accountNumber, String newHolderName;
void deleteAccountlong accountNumber;
void depositlong accountNumber, double amount;
void withdrawlong accountNumber, double amount;
void printAllAccountSummariesByHolderNameString holderName;
class BankingSystem implements IBankingSystem
private List accountList new ArrayList;
public void printAllAccountsSummary
for Account account : accountList
printAccountSummaryaccount;
private void printAccountSummaryAccount account
String summary String.formataccountNumber: d holderName: s
balance: f account.accountNumber,
account.holderName, account.balance;
printMessagesummary;
public void printAccountSummarylong accountNumber
Account account findAccountaccountNumber;
printAccountSummaryaccount;
Use this to print messages.
public void printMessageString message
System.out.printlnmessage;
Use this method as a utility to locate the requested account.
For example, you can use this when updating an account.
private Account findAccountlong accountNumber
Write your code here...
Implement the IBankingSystem interface
Write your code here...
Hint: Use switch
class Solution
public static void mainString args throws IOException
BankingSystem bank new BankingSystem;
input handling
BufferedReader bufferedReader new BufferedReadernew
InputStreamReaderSystemin;
int operationCount
Integer.parseIntbufferedReaderreadLinereplaceAlls$split
trim;
bufferedReader.readLine;
IntStream.range operationCountforEachopCountItr
try
List theInput
Stream.ofbufferedReaderreadLinereplaceAlls$split
collecttoList;
String action theInput.get;
String arg theInput.size theInput.gettrim : null;
String arg theInput.size theInput.gettrim : null;
String arg theInput.size theInput.gettrim : null;
ProcessInputsbank action, arg arg arg;
catch IOException exception
throw new RuntimeExceptionexception;
;
bufferedReader.close;
private static void ProcessInputsBankingSystem bank, String action, String
arg String arg String arg
long accountNumber;
String holderName;
double amount;
switch action
case "createAccount":
accountNumber Long.parseLongarg;
holderName arg;
amount Double.parseDoublearg;
Account account new AccountaccountNumber holderName, amount;
bank.createAccountaccount;
break;
case "deleteAccount":
accountNumber Long.parseLongarg;
bank.deleteAccountaccountNumber;
break;
case "deposit":
accountNumber Long.parseLongarg;
amount Double.parseDoublearg;
bank.depositaccountNumber amount;
break;
case "printAllAccountsSummary":
bank.printAllAccountsSummary;
break;
case "printAllAccountSummariesByHolderName":
holderName arg;
bank.printAllAccountSummariesByHolderNameholderName;
break;
case "printAccountSummary":
accountNumber Long.parseLongarg;
bank.printAccountSummaryaccountNumber;
break;
case "updateAccountName":
accountNumber Long.parseLongarg;
holderName arg;
bank.updateAccountNameaccountNumber holderName;
break;
case "withdraw":
accountNumber Long.parseLongarg;
amount Double.parseDoublearg;
bank.withdrawaccountNumber amount;
break;
default:
throw new IllegalArgumentExceptionNo know action name was
provided.";
Sample Input
OPERATIONCOUNT
createAccount, "Alice",
printAccountSummary,
Sample Output
accountNumber: holderName: "Alice", balance:
Sample Input
OPERATIONCOUNT
createAccount, "Alice",
updateAccountName, "Bob"
Sample Output
ACCOUNTNOTFOUND
Sample Input
OPERATIONCOUNT
createAccount, "Alice",
updateAccountName, "Bob"
printAccountSummary,
Sample Output
accountNumber: holderName: "Bob", balance:
Sample Input
OPERATIONCOUNT
createAccount, "Alice",
withdraw,
Sample Output
ACCOUNTNOTFOUND
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started