For Dutch Euro use: .getCurrencyInstance(new Locale(“nl”, “NL”))
For Swiss Franc use: .getCurrencyInstance(new Locale(“de”, “CH”))
import java.text.NumberFormat;
import java.util.Locale;
public class prog_002_variables {
public static void main(String[] args){
String message;
int year;
double prijs;
message = "De beste wensen voor: ";
year = 2025;
prijs = 2.50;
// Combine the creation of the Locale and the NumberFormat in one line
NumberFormat currencyFormat;
currencyFormat = NumberFormat.getCurrencyInstance(new Locale("nl", "NL"));
System.out.println(message + year + ", een frikandel kost nu: " + currencyFormat.format(prijs));
currencyFormat = NumberFormat.getCurrencyInstance(new Locale("de", "CH"));
System.out.println(message + year + ", een frikandel kost nu: " + currencyFormat.format(prijs));
}
}