I'm trying to get each variable to print out with two decimal places but I do not know what I'm doing wrong. Any help?
System.out.printf("%.2",custNum + "\t" + beginBal + " \t " + financeCharge + "\t\t" +
purchases + " \t " + payments + "\t\t" + endBal);
Your format String
should be %.2f
and one for each term. Something like,
System.out.printf("%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f%n", custNum, beginBal,
financeCharge, purchases, payments, endBal);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.