Ok, how do I round a decimal to the 2nd decimal place instead of just the first decimal place? I had to create a menu, where the "customer" orders food and we had to have the subtotal and tax and tip included. My code works fine unless the grand total is something like $3.8 when it should be $3.80. How can I fix that by only using Math.round()? My code for the money part of the menu is
double SUBtotal = subTotal * 100.00;
System.out.println("Your current total is: $" +
Math.round(SUBtotal)/100.00);
System.out.println("Options:");
System.out.println(" 1. Order another item");
System.out.println(" 2. Checkout");
mainOp = scan.nextInt();
if (mainOp==2)
{
System.out.println(Order);
double tax = subTotal * 0.0825;
double taxSubtotal = tax + subTotal;
double please = taxSubtotal * 100.00;
double taxSubtotal2 = Math.round(please) / 100.00;
System.out.println("\nSubtotal (with tax): $ " + taxSubtotal2);
System.out.println("Tip: $");
double tip = scan.nextDouble();
double total = taxSubtotal + tip;
double total2 = total * 100.00;
double total3 = Math.round(total2) /100.00;
System.out.println("Final Total: $" + total3);
System.out.println();
System.out.println("Thank You For Ordering!");
}
Thank you very much!