Notities

Notities

ing. M.A.C.M. (Martijn) van den Boom

Computer Infrastructure Architect
ingenieur, docent en mentor

Social Media Links:

ing. M.A.C.M. (Martijn) van den Boom

1 minuut leestijd

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));

    }

}

Recente berichten

Categorieën

Over Mij

Sponsor me link:
ko-fi.com/martijnvandenboom
paypal.me/ingmacmvandenboom
buymeacoffee.com/ingvdboom