-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
61 lines (55 loc) · 1.66 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
60
61
<!DOCTYPE html>
<html>
<head>
<meta charset="uyf-8">
<meta name="viewport" content="width-device-width, initial-scale=1">
<title>Aplikasi Kalkulator Matematika</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<div class="title">
<h1>Kalkulator Segi Empat</h1>
<p>Dibuat dengan HTML, CSS, dan Javacript</p>
</div>
<hr>
<div class="content">
<div class="left-content">
<img src="segiempat.png">
</div>
<div class="right-content">
<h2>Menghitung Luas dan Keliling</h2>
<br>
<label>Panjang:</label>
<input id="p" type="number" name="panjang"placeholder= "Masukan Panjang">
<br>
<label>Lebar:</label>
<input id="l" type="number" name="Lebar"placeholder= "Masukan 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>@copyright Kalk App By Silvi</p>
</footer>
</div>
<script type="text/javascript">
function hitungLuas () {
let panjang = document.getElementById('p').value;
let lebar = document.getElementById('l').value;
let luas = panjang * lebar;
document.getElementById('luas').innerHTML = ` adalah ${luas} cm<sup>2</sup>`;
}
function hitungKeliling () {
let panjang = document.getElementById('p').value;
let lebar = document.getElementById('l').value;
let keliling = 2*panjang + 2*lebar;
document.getElementById('keliling').innerHTML = ` adalah ${keliling} cm `;
}
</script>
</body>
</html>