to try
System.out.printf("%-25s %10s %10s %10s", item, quantity, "$" + price, "$" + total);
Output
Oranges 3 $3.0 $9.0
or, best of all, use the formatting method
String format(double d) { return String.format("$%.2f", d); } ... System.out.printf("%-25s %10s %10s %10s", item, quantity, format(price), format(total));
Output
Oranges 3 $3.00 $9.00
source share