for (ctr = 0; ctr<cost.length; ctr++) {
cost[ctr] = price[ctr] * qty[ctr];
totalCost = totalCost + cost[ctr];
aveCost = totalCost / cost.length; }
System.out.printf("Average Cost: %.2f\n\n", aveCost);
with this code the output will be, for example:
Average Cost: 15900.00
I want my output to look like this
Average Cost: 15,900.00
*the output number can change depends on what is inside the array. Is there an easy way? I look all over the internet and I all I see are those very long codes that takes up like 1 whole bond paper just to put the comma(,). I just want a very simple code which even a newbie like me can understand, I'm still not very good at programming.