it's my first time to do java. We are currently learning it but we have not really touched up on formatting and i was wondering if anyone could help me with my code. So my code is as follows:
public void displayAllOrder()
{
System.out.println("Initial Cost" + "\t" + "Voucher Code Used" + "\t" + "Voucher Amount Deducted" + "\t\t" + "Final Cost" + "\t" + "Shipping ID" + "\t" + "Shipment Status");
for (int i = 0; i <= currentIndex; i++)
{
String strInitialCost = String.format("%.2f", initialCost[i]);
String strFinalCost = String.format("%.2f", finalCost[i]);
System.out.println("$"+strInitialCost + "\t\t" + voucherCode[i] + "\t\t\t" + "$"+voucherAmount[i] + "\t\t\t" + "$"+strFinalCost + "\t" + shippingID[i] + "\t\t" + shipmentStatus[i]);
}
It aligns perfectly if the input is large but it is not aligned if the calculated input is small. Example output as follows:
I hope someone could help me understand with regards to this issue. Thank you.