forked from lianeddy/Fundamental-JC1504
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercise1.html
30 lines (24 loc) · 1.04 KB
/
exercise1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<script>
var apple, grape, orange; // Simpan data kuantitas
var priceApple = 10000
var priceGrape = 15000
var priceOrange = 20000
apple = prompt('Masukkan jumlah Apel Rp.10000') // Keluarin pop up di browser
grape = prompt('Masukkan jumlah Anggur Rp.15000')
orange = prompt('Masukkan jumlah jeruk Rp.20000')
// Math.pow(1,2);
// Math.pow(3,2); => 3^2 = 9
// Math.pow(2,2); => 2^2 = 4
var totalApple = apple * priceApple // Harga total untuk setiap buah
var totalGrape = grape * priceGrape
var totalOrange = orange * priceOrange
var totalPrice = totalApple + totalGrape + totalOrange
var pajak = totalPrice * 0.05;
alert(
'Detail Belanja \n\n' +
'Apple : ' + apple + ' x ' + priceApple + ' = ' + totalApple + '\n' +
'Grape : ' + grape + ' x ' + priceGrape + ' = ' + totalGrape + '\n' +
'Orange : ' + orange + ' x ' + priceOrange + ' = ' + totalOrange + '\n\n'+
'Total : ' + totalPrice + ' + 5% Tax ' + pajak + ' = Rp.' + (totalPrice+pajak)
)
</script>