Проблем с формата на резултата Java
Здравейте, когато на този код въведа входни данни 40.8 20 25 30 50 10 получавам 418.2, а в условието на задачата се изисква 418.20 (нула отзад), някой може ли да ми каже как да го форматирам?
import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double priceOfTheTrip = Double.parseDouble(input.nextLine());
int numberOfPuzzles = Integer.parseInt(input.nextLine());
int numberOfTalkingDolls = Integer.parseInt(input.nextLine());
int numberOfTeddyBears = Integer.parseInt(input.nextLine());
int numberOfMinions = Integer.parseInt(input.nextLine());
int numberOfTrucks = Integer.parseInt(input.nextLine());
double moneyOfPuzzles = numberOfPuzzles * 2.60;
double moneyOfDolls = numberOfTalkingDolls * 3;
double moneyOfBears = numberOfTeddyBears * 4.10;
double moneyOfMinions = numberOfMinions * 8.20;
double monewOfTrucks = numberOfTrucks * 2;
double allMoney = moneyOfPuzzles + moneyOfDolls + moneyOfBears + moneyOfMinions + monewOfTrucks;
int allToys = numberOfPuzzles + numberOfTalkingDolls + numberOfTeddyBears + numberOfMinions + numberOfTrucks;
double discount = allMoney * 0.25;
if (allToys >= 50){
allMoney = allMoney - discount;
}
double shopRent = allMoney * 0.10;
allMoney = allMoney - shopRent;
double notEnoughMoney = priceOfTheTrip - allMoney;
double remainingMoney = allMoney-priceOfTheTrip;
DecimalFormat format = new DecimalFormat("#.##");
if (allMoney >= priceOfTheTrip){
System.out.println("Yes! " + format.format(remainingMoney) + " lv left.");
}else System.out.println("Not enough money! " + format.format(notEnoughMoney) + " lv needed.");
}
}