Algorithm/Algorithm__hackerrank-Java

Currency Formatter

말하는감자 2022. 6. 21. 16:23
import java.util.*;
import java.text.*;

public class Solution {
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double payment = scanner.nextDouble();
        scanner.close();
        
        // Write your code here.
        NumberFormat us = NumberFormat.getCurrencyInstance(Locale.US);
        NumberFormat india = NumberFormat.getCurrencyInstance(new Locale("en", "IN"));
        NumberFormat china = NumberFormat.getCurrencyInstance(Locale.CHINA);
        NumberFormat france = NumberFormat.getCurrencyInstance(Locale.FRANCE);
        
        System.out.println("US: " + us.format(payment));
        System.out.println("India: " + india.format(payment));
        System.out.println("China: " + china.format(payment));
        System.out.println("France: " + france.format(payment));
    }
}

'Algorithm > Algorithm__hackerrank-Java' 카테고리의 다른 글

Dequeue  (0) 2022.06.21
Sort  (0) 2022.06.21
Currency Formatter  (0) 2022.06.21
Date And Time  (0) 2022.06.21
End-of-file  (0) 2022.06.21
Introduction - Java Datatypes  (0) 2022.06.21