java - formatting toString method using String.format -
required output: code: 123 title: booka fees(sgd): $20.00 loan duration: 3 wks
return string.format("%-20s%-20s%\n", "code: " + code, "title: " + title, "%.2f\nfees(sgd): $" + fees, "lesson duration: " + lessonduration + "wks");
it returns first 3 (code, title, fees) not loan duration. put in %.2f fees of 2 decimal place?
your question asks "loan duration", example code uses "lesson duration". problem.
that %.2f should work setting 2 decimal places. how behaving?
Comments
Post a Comment