Skip to content

Repository files navigation

CountIntOverPower

publicclassGblFunction {
publicstaticStringsaparator(Stringvalue) {
if (value == null || value.equals("") || value.equals("0") || value.equals("0.0")) {
return"0";
}
if (value.contains(",")){
value = value.substring(0, value.indexOf(","));
}
value = idrComma(value);
returnvalue.substring(0, value.indexOf(","));
}
publicstaticStringidrComma(Stringvalue) {
if (value == null || value.equals("") || value.equals("0") || value.equals("0.0")) {
return"0";
} else {
if (value.contains(",")){
value = value.substring(0, value.indexOf(","));
}
LocalelocaleID = newLocale("in", "ID");
NumberFormatformatRupiah = NumberFormat.getCurrencyInstance(localeID);
returnformatRupiah.format(Double.valueOf(value)).replace("Rp", "");
}
}
publicstaticStringidr(Stringvalue) {
return"Rp " + idrComma(value).replace(",00","");
}
}
publicclassMainActivityextendsAppCompatActivity {
privateList<String> productBuys;
privateTextViewtv1;
privateTextViewtv2;
privateTextViewtv3;
@OverrideprotectedvoidonCreate(BundlesavedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv1 = findViewById(R.id.tv1);
tv2 = findViewById(R.id.tv2);
tv3 = findViewById(R.id.tv3);
productBuys = newArrayList<>();
productBuys.add("9999");
productBuys.add("9999");
productBuys.add("9999");
productBuys.add("9999");
productBuys.add("9999");
productBuys.add("9999");
productBuys.add("9999");
productBuys.add("9999");
productBuys.add("9999");
hitungTotal();
}
publicvoidhitungTotal() {
doublesum = 0;
for (intj = 0; j < productBuys.size(); j++) {
if (productBuys.get(j) != null) {
doubleharga1 = Double.parseDouble("9999999");
doubleqty1 = Double.parseDouble(productBuys.get(j));
Doublesubtotal1 = (harga1 * qty1);
sum = Math.round(subtotal1 + sum);
}
}
tv1.setText(saparator(String.valueOf(sum))); // 8.99909910009E11 = 899.909.910.009tv2.setText(idrComma(String.valueOf(sum))); // 8.99909910009E11 = 899.909.910.009,00tv3.setText(idr(String.valueOf(sum))); // 8.99909910009E11 = Rp 899.909.910.009
}
}

Copyright 2021 M. Fadli Zein

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages