Skip to content

Commit f56a4f9

Browse files
Add files via upload
1 parent 975299d commit f56a4f9

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

Praktikum/Praktikum1/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@
3030
<button onclick="appendNumber('3')">3</button>
3131
<button onclick="appendNumber('%')">%</button>
3232

33-
3433
<button onclick="appendNumber('0')" class="zero">0</button>
34+
<button onclick="appendNumber('^')">^</button>
3535
<button onclick="appendNumber('.')">.</button>
3636
<button onclick="calculate()">=</button>
37-
3837
</div>
3938
</div>
4039
<script src="script.js"></script>
2.27 MB
Loading

Praktikum/Praktikum1/script.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ let display = document.getElementById('display');
33

44
// Fungsi untuk menambah angka/simbol ke display
55
function appendNumber(number) {
6+
// Jika ada tulisan "Error", kita hapus dulu sebelum menambahkan angka
7+
if (display.value === 'Error') {
8+
display.value = '';
9+
}
610
display.value += number;
711
}
812

@@ -19,10 +23,10 @@ function deleteLast() {
1923
// Fungsi untuk menghitung hasil
2024
function calculate() {
2125
try {
22-
// Tangani simbol '%' untuk mengkonversinya menjadi perhitungan persentase
23-
let expression = display.value.replace(/([0-9]+)%/g, "(($1)/100)");
26+
let expression = display.value
27+
.replace(/([0-9]+)%/g, "(($1)/100)") // Ubah % jadi operasi persentase
28+
.replace(/\^/g, "**"); // Ubah ^ jadi operasi pangkat
2429

25-
// Evaluasi ekspresi yang sudah dimodifikasi
2630
display.value = eval(expression);
2731
} catch (error) {
2832
display.value = 'Error';

Praktikum/Praktikum1/style.css

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@
55
}
66

77
body {
8+
font-family: Arial, sans-serif;
9+
background-image: url('purple-aesthetic-rain.gif');
10+
background-size: cover;
11+
background-position: center;
812
display: flex;
913
justify-content: center;
1014
align-items: center;
1115
height: 100vh;
12-
background-color: #000000;
13-
font-family: 'Arial', sans-serif;
1416
}
1517

1618
.calculator {
19+
1720
width: 320px;
1821
padding: 20px;
19-
background-color: #00e1ff;
22+
background-color: #2a0a51;
23+
color: #fff;
2024
border-radius: 10px;
2125
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
2226
}
@@ -48,14 +52,20 @@ button {
4852
border-radius: 5px;
4953
cursor: pointer;
5054
transition: background-color 0.3s;
55+
padding: 10px; /* Menambah padding untuk semua tombol */
5156
}
5257

5358
button:hover {
5459
background-color: #f2ff00;
5560
}
5661

5762
button.zero {
58-
grid-column: span 2;
63+
grid-column: span 2; /* Membuat tombol 0 selebar 2 kolom */
64+
}
65+
66+
button.equal {
67+
grid-column: span 2; /* Membuat tombol = selebar 2 kolom */
68+
height: 130px; /* Memperpanjang tombol = */
5969
}
6070

6171
button:active {

0 commit comments

Comments
 (0)