Quick actions

cmd+k|ctrl+k

Navigation

Languages

Penghitung discount + PPN

Snippet info

Language

JavaScript

Visibility

public

Author

riki.whyudi

Created

2022-09-13T22:23:19.186189Z

Updated

2022-10-12T14:54:35.44888Z

function discount(input) {
  const ppn = 15;
  const harga = 500000;
  const idr = new Intl.NumberFormat("id-ID");
  const disc = Number(input);
  const ppNegara = Number(ppn / 100) * harga;
  const potongan = Number(disc / 100) * harga;
  const total = Number(harga - potongan);
  const diBayar = Number(total + ppNegara);
    
    return console.log(`
    =======( RIKI WAHYUDI )======= \n
    Harga: Rp.${idr.format(harga)}
    Potongan: ${disc}%
    PPN: +${ppn}%
    Harga Discount: Rp.${idr.format(total)} \n
    ==============================
    Total: Rp.${idr.format(diBayar)}
    
    `)
}

 process.stdin.resume();
 process.stdin.setEncoding("ascii");
 _input = "";
 process.stdin.on("data", function (input) {
     _input += input;
 });
 
 process.stdin.on("end", function () {
    discount(_input);
 });
 
INFO