Twentythree Zone

import java.io.*;
import java.text.*;
public class FormatAngka
{
public static void main (String args [])
{
double A=20.0,B=5000.0,C=807.0,D;
{
System.out.println(" ");
System.out.println("Contoh Bentuk Format Angka ");
System.out.println(" ========================= ");
System.out.println(" ");
System.out.println("Diketahui A= "+A);
System.out.println("Diketahui B= "+B);
System.out.println("Diketahui C= "+C);
D = A * B * C ;
System.out.println(" ");
System.out.println("Hasil dari A X BX C = ?");
System.out.println("Hitung : "+A+" X "+B+" X "+C);

// Format Angka
NumberFormat nf = NumberFormat.getNumberInstance();
String s1 = nf.format (D);
System.out.println("hasil Format Angka = "+s1);

// Format mata Uang
NumberFormat nfC = NumberFormat.getCurrencyInstance();
String s2 = nfC.format (D);
System.out.println("hasil Format Mata Uang = "+s2);
}
}
}

Categories:

Leave a Reply