Senin, 01 Juni 2009

Menghitung Harga beserta Diskonnya

dari soal sebagai berikut :

BarangJumlahHarga satuan
CPU75500000
Printer51500000
Scaner82700000
Monitor103500000
Hardisk61200000
Mouse12100000
Webcam151000000

maka didapatkan harga barang beserta diskon dengan rumus di bawah ini :

awk 'BEGIN{printf "%-10s %-10s %-10s %-10s %-10s %s\n",
"BARANG","JUMLAH","HARGA SATUAN","TOTAL","DISCOUNT",
"BAYAR"}
{if($2>=5 && $2 <10){printf "%-10s %-10s %-10s %-10s %-10s %s\n", $1,$2,$3,$4=$2*$3,$5=0.1*$4,$6=$4-$5 }}
{if($2>=10){printf "%-10s %-10s %-10s %-10s %-10s %s\n", $1,$2,$3,$4=$2*$3,$5=0.2*$4,$6=$4-$5 }}' barang

0 komentar:


Free Blogspot Templates by Isnaini Dot Com and Bridal Dresses. Powered by Blogger