-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
59 lines (53 loc) · 1.59 KB
/
index.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Aplikasi kalkulator Matematika sederhana</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="container">
<div class="title">
<h1>Kalkulator Segi Empat</h1>
<p>Dibuat dengan HTML, CSS, dan Javascrpit</p>
</div>
<hr>
<div class="content">
<div class="left-content">
<img src="segi empat.png">
</div>
<div class="right-content">
<h2>Menghitung Luas dan Keliling</h2>
<br>
<label>Panjang</label>
<input id="p" type="number" name="panjang" placeholder="Masukkan Panjang">
<br>
<label>Lebar</label>
<input id="l" type="number" name="lebar" placeholder="Masukkan Lebar">
<br>
<button onclick="hitungLuas()">Hitung Luas :</button>
<span id="luas"></span>
<br>
<button onclick="hitungKeliling()">Hitung Keliling :</button>
<span id="keliling"></span>
</div>
</div>
<footer>
<p>© Kalk App by Michael X3</p>
</footer>
<script type="text/javascript">
function hitungLuas () {
var panjang = document.getElementById('p').value;
var lebar = document.getElementById('l').value;
var luas = panjang * lebar;
document.getElementById('luas').innerHTML = ` adalah ${luas} cm<sup>2</sup>`;
}
function hitungKeliling () {
var panjang = document.getElementById('p').value;
var lebar = document.getElementById('l').value;
var keliling = 2*panjang + 2*lebar;
document.getElementById('keliling').innerHTML = ` adalah ${keliling} cm`;
}
</script>
</body>
</html>