Minggu, 02 Agustus 2020

Android Code Format Rupiah

   String RP(double rp){
      rp=Math.ceil(rp);
      Locale localeID = new Locale("in", "ID");
      NumberFormat formatRupiah = NumberFormat.getCurrencyInstance(localeID);
      String hs=formatRupiah.format(rp);
      return hs;
      }  




Implmntasi:
String txtnominal=txtNominal.getText().toString();
        double NOMINAL=0;
       
       
        shasil="";
        NOMINAL=Double.parseDouble(txtnominal);;
       
        if(jw>0){
for(int  j=0;j<jw;j++){
if(ar[j].equalsIgnoreCase("Ayah")){
shasil+=ar[j]+" ("+String.valueOf(int1)+") @Rp."+RP((drumus_1 *  NOMINAL)/int1)+"\n";
}
else if(ar[j].equalsIgnoreCase("Ibu")){
shasil+=ar[j]+" ("+String.valueOf(int2)+") @Rp."+RP((drumus_1 *  NOMINAL)/int2)+"\n";
}
else if(ar[j].equalsIgnoreCase("Saudara Laki-laki SeIbu")){
shasil+=ar[j]+" ("+String.valueOf(int3)+") @Rp."+RP((drumus_1 *  NOMINAL)/int3)+"\n";
}
else if(ar[j].equalsIgnoreCase("Saudara Perempuan SeIbu")){
shasil+=ar[j]+" ("+String.valueOf(int4)+") @Rp."+RP((drumus_1 *  NOMINAL)/int4)+"\n";
}
else if(ar[j].equalsIgnoreCase("Anak Laki-laki")){
shasil+=ar[j]+" ("+String.valueOf(int5)+") @Rp."+RP((drumus_1 *  NOMINAL)/int5)+"\n";
}


Tidak ada komentar:

Posting Komentar