For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
The java labs we have completed consisted of hacking the code to produce the desired output.
I am interested in tidying up the output to do the following:
Sounds like you might be interested in Java Regular Expressions (regex) and pattern matching. I've found regular expressions useful for formatting and searching Strings and numbers. There is a tutorial from Oracle (https://docs.oracle.com/javase/tutorial/essential/regex/ ). I've also had luck googling for regular expression examples, since there's so many tricks, options, characters to keep track of.
I am using something like the one below. I don't know if that is going to help in
I am interested in tidying up the output to do the following:Strings and value in two separate columns (???)
public void printDetails() {
System.out.println(String.format("Account Owner: %s", accountOwner));
System.out.println(String.format("Account Type: %s", accountType));
DecimalFormat df = new DecimalFormat("$ #,##0.00");
String formattedBal = df.format(balance);
System.out.println(String.format("Balance for customer [%s]: %s", accountOwner, formattedBal));
}