I have a code where an individual orders a certain number of coffees and coffee shots in each cup, and the program calculates the total price (purchasePrice). However, when i output the purchase price as a double, it only outputs a number with 1 decimal place. How can i change it to output with 2 decimal places.
double purchasePrice = 0;
for (counting = 0; counting < coffeeCups; counting++) {
System.out.println("Cup " + (counting + 1) + " has " + coffeeShots[counting] + " shot(s) and will cost $" + (2 + coffeeShots[counting]) + "\n");
purchasePrice+= 2 + (coffeeShots[counting]);
}
System.out.println(coffeeCups + " coffees to purchase.");
System.out.println("\nPurchase price is $" + purchasePrice + ".");