Soal Runtunan 1. Diketahui algoritma berikut ini Algoritma UtakAtik1 Deskripsi Read (A) B0.5* A + 15 CA* A -3 DB+C Write(B,C,D) Tentukan keluaran algoritma jika a. A = 4 b. A = 6 2. Terjemahkan algoritma soal no 1 ke dalam bentuk flowchart 3. Diketahui algoritma berikut ini Algoritma UtakAtik1 Deskripsi Read (A,B) C 0.5 (A + B) DAC - 3 E + C + D Write(C,D,E) c. A = -3 * Tentukan keluaran algoritma jika masukan A dan B masing-masing : a. 5 dan 4 b. -2 dan 9 c. 3 dan 6 4. Buatlah algoritma teks dan flowchart yang menampilkan tulisan “Halo” seban tiga kali
- Kotak dengan tulisan "Assign" digunakan untuk menyimpan nilai ke dalam variabel.
- Kotak dengan tulisan "Display" digunakan untuk menampilkan teks ke layar.
- Kotak dengan tanda panah dan tulisan "Loop" menunjukkan perulangan.
- Angka "3" di kotak Loop menunjukkan jumlah perulangan.
0 votes Thanks 0
kibidhjw
1. a. Jika A = 4: B = 0.5 * A + 15 = 0.5 * 4 + 15 = 2 + 15 = 17 C = A * A - 3 = 4 * 4 - 3 = 16 - 3 = 13 D = B + C = 17 + 13 = 30 Keluaran: B = 17, C = 13, D = 30
b. Jika A = 6: B = 0.5 * A + 15 = 0.5 * 6 + 15 = 3 + 15 = 18 C = A * A - 3 = 6 * 6 - 3 = 36 - 3 = 33 D = B + C = 18 + 33 = 51 Keluaran: B = 18, C = 33, D = 51
2. Berikut adalah flowchart untuk Algoritma UtakAtik1:
``` +-------+ +-------+ +-------+ | Start | ----> | Read A| ----> | B = 0.5 * A + 15 | +-------+ +-------+ +-------+ | V +-------+ | Read B| +-------+ | V +-------+ | C = 0.5 * (A + B) | +-------+ | V +-------+ | D = C - 3 | +-------+ | V +-------+ | E = C + D | +-------+ | V +-------+ | Write | +-------+ ```
3. a. Jika A = 5 dan B = 4: C = 0.5 * (A + B) = 0.5 * (5 + 4) = 0.5 * 9 = 4.5 D = C - 3 = 4.5 - 3 = 1.5 E = C + D = 4.5 + 1.5 = 6 Keluaran: C = 4.5, D = 1.5, E = 6
b. Jika A = -2 dan B = 9: C = 0.5 * (A + B) = 0.5 * (-2 + 9) = 0.5 * 7 = 3.5 D = C - 3 = 3.5 - 3 = 0.5 E = C + D = 3.5 + 0.5 = 4 Keluaran: C = 3.5, D = 0.5, E = 4
c. Jika A = 3 dan B = 6: C = 0.5 * (A + B) = 0.5 * (3 + 6) = 0.5 * 9 = 4.5 D = C - 3 = 4.5 - 3 = 1.5 E = C + D = 4.5 + 1.5 = 6 Keluaran: C = 4.5, D = 1.5, E = 6
4. Algoritma teks untuk menampilkan tulisan "Halo"
sebanyak tiga kali adalah: ``` Deskripsi: 1. Set variabel jumlah_tulisan = 3 2. Set variabel counter = 1 3. Selama counter <= jumlah_tulisan, lakukan langkah-langkah berikut ini: a. Tulis "Halo" b. Tambahkan 1 ke nilai counter 4. Selesai
Flowchart: +-------+ | Start | +-------+ | V +---------------------+ | Set jumlah_tulisan = 3 | +---------------------+ | V +-------------------+ | Set counter = 1 | +-------------------+ | V +------------------------+ | counter <= jumlah_tulisan? | +------------------------+ | V +-----------------+ | Tulis "Halo" | +-----------------+ | V +--------------------+ | Tambahkan 1 ke counter | +--------------------+ | V +------------------------+ | counter <= jumlah_tulisan? | +------------------------+ | V +-----------------+ | Tulis "Halo" | +-----------------+ | V +--------------------+ | Tambahkan 1 ke counter | +--------------------+ | V +------------------------+ | counter <= jumlah_tulisan? | +------------------------+ | V +-----------------+ | Tulis "Halo" | +-----------------+ | V +------------------------+ | Tambahkan 1 ke counter | +------------------------+ | V +------------------------+ | counter <= jumlah_tulisan? | +------------------------+ | X +-------+ | End | +-------+ ```
1. a. Untuk A = 4:
B = 0.5 * A + 15
= 0.5 * 4 + 15
= 2 + 15
= 17
C = A * A - 3
= 4 * 4 - 3
= 16 - 3
= 13
D = B + C
= 17 + 13
= 30
Keluaran: B = 17, C = 13, D = 30
b. Untuk A = 6:
B = 0.5 * A + 15
= 0.5 * 6 + 15
= 3 + 15
= 18
C = A * A - 3
= 6 * 6 - 3
= 36 - 3
= 33
D = B + C
= 18 + 33
= 51
Keluaran: B = 18, C = 33, D = 51
2. Berikut adalah flowchart dari Algoritma UtakAtik1:
```
[Start] --> [Input A] --> [Calculate B = 0.5 * A + 15] --> [Calculate C = A * A - 3] --> [Calculate D = B + C] --> [Output B, C, D] --> [End]
```
3. a. Untuk A = 5 dan B = 4:
C = 0.5 * (A + B)
= 0.5 * (5 + 4)
= 0.5 * 9
= 4.5
D = A * C - 3
= 5 * 4.5 - 3
= 22.5 - 3
= 19.5
E = B + C + D
= 4 + 4.5 + 19.5
= 28
Keluaran: C = 4.5, D = 19.5, E = 28
b. Untuk A = -2 dan B = 9:
C = 0.5 * (A + B)
= 0.5 * (-2 + 9)
= 0.5 * 7
= 3.5
D = A * C - 3
= -2 * 3.5 - 3
= -7 - 3
= -10
E = B + C + D
= 9 + 3.5 - 10
= 2.5
Keluaran: C = 3.5, D = -10, E = 2.5
c. Untuk A = 3 dan B = 6:
C = 0.5 * (A + B)
= 0.5 * (3 + 6)
= 0.5 * 9
= 4.5
D = A * C - 3
= 3 * 4.5 - 3
= 13.5 - 3
= 10.5
E = B + C + D
= 6 + 4.5 + 10.5
= 21
Keluaran: C = 4.5, D = 10
.5, E = 21
4. Algoritma teks untuk menampilkan tulisan "Halo" sebanyak tiga kali:
```
1. Simpan teks "Halo" ke dalam variabel Pesan
2. Ulangi 3 kali:
- Tampilkan Pesan
Akhir
```
Flowchart untuk algoritma di atas:
```
[Start] --> [Assign "Halo" to Pesan] --> [Loop 3 times] --> [Display Pesan] --> [End]
```
Keterangan:
- Kotak dengan tulisan "Assign" digunakan untuk menyimpan nilai ke dalam variabel.
- Kotak dengan tulisan "Display" digunakan untuk menampilkan teks ke layar.
- Kotak dengan tanda panah dan tulisan "Loop" menunjukkan perulangan.
- Angka "3" di kotak Loop menunjukkan jumlah perulangan.
B = 0.5 * A + 15 = 0.5 * 4 + 15 = 2 + 15 = 17
C = A * A - 3 = 4 * 4 - 3 = 16 - 3 = 13
D = B + C = 17 + 13 = 30
Keluaran: B = 17, C = 13, D = 30
b. Jika A = 6:
B = 0.5 * A + 15 = 0.5 * 6 + 15 = 3 + 15 = 18
C = A * A - 3 = 6 * 6 - 3 = 36 - 3 = 33
D = B + C = 18 + 33 = 51
Keluaran: B = 18, C = 33, D = 51
2. Berikut adalah flowchart untuk Algoritma UtakAtik1:
```
+-------+ +-------+ +-------+
| Start | ----> | Read A| ----> | B = 0.5 * A + 15 |
+-------+ +-------+ +-------+
|
V
+-------+
| Read B|
+-------+
|
V
+-------+
| C = 0.5 * (A + B) |
+-------+
|
V
+-------+
| D = C - 3 |
+-------+
|
V
+-------+
| E = C + D |
+-------+
|
V
+-------+
| Write |
+-------+
```
3. a. Jika A = 5 dan B = 4:
C = 0.5 * (A + B) = 0.5 * (5 + 4) = 0.5 * 9 = 4.5
D = C - 3 = 4.5 - 3 = 1.5
E = C + D = 4.5 + 1.5 = 6
Keluaran: C = 4.5, D = 1.5, E = 6
b. Jika A = -2 dan B = 9:
C = 0.5 * (A + B) = 0.5 * (-2 + 9) = 0.5 * 7 = 3.5
D = C - 3 = 3.5 - 3 = 0.5
E = C + D = 3.5 + 0.5 = 4
Keluaran: C = 3.5, D = 0.5, E = 4
c. Jika A = 3 dan B = 6:
C = 0.5 * (A + B) = 0.5 * (3 + 6) = 0.5 * 9 = 4.5
D = C - 3 = 4.5 - 3 = 1.5
E = C + D = 4.5 + 1.5 = 6
Keluaran: C = 4.5, D = 1.5, E = 6
4. Algoritma teks untuk menampilkan tulisan "Halo"
sebanyak tiga kali adalah:
```
Deskripsi:
1. Set variabel jumlah_tulisan = 3
2. Set variabel counter = 1
3. Selama counter <= jumlah_tulisan, lakukan langkah-langkah berikut ini:
a. Tulis "Halo"
b. Tambahkan 1 ke nilai counter
4. Selesai
Flowchart:
+-------+
| Start |
+-------+
|
V
+---------------------+
| Set jumlah_tulisan = 3 |
+---------------------+
|
V
+-------------------+
| Set counter = 1 |
+-------------------+
|
V
+------------------------+
| counter <= jumlah_tulisan? |
+------------------------+
|
V
+-----------------+
| Tulis "Halo" |
+-----------------+
|
V
+--------------------+
| Tambahkan 1 ke counter |
+--------------------+
|
V
+------------------------+
| counter <= jumlah_tulisan? |
+------------------------+
|
V
+-----------------+
| Tulis "Halo" |
+-----------------+
|
V
+--------------------+
| Tambahkan 1 ke counter |
+--------------------+
|
V
+------------------------+
| counter <= jumlah_tulisan? |
+------------------------+
|
V
+-----------------+
| Tulis "Halo" |
+-----------------+
|
V
+------------------------+
| Tambahkan 1 ke counter |
+------------------------+
|
V
+------------------------+
| counter <= jumlah_tulisan? |
+------------------------+
|
X
+-------+
| End |
+-------+
```
Semoga ini membantu!