Files
flowgorithm/MG5_n1.fprg
2026-03-12 04:15:07 +00:00

91 lines
5.7 KiB
XML

<?xml version="1.0"?>
<flowgorithm fileversion="4.2">
<attributes>
<attribute name="name" value="GuessThePrice"/>
<attribute name="authors" value="yvl"/>
<attribute name="about" value=""/>
<attribute name="saved" value="2026-03-12 10:14:20 AM"/>
<attribute name="created" value="eXZsO1lVVkxJQU5fV0FTX0hFUkU7MjAyNi0wMy0xMjswODozMjoyMyBBTTsxMTEx"/>
<attribute name="edited" value="eXZsO1lVVkxJQU5fV0FTX0hFUkU7MjAyNi0wMy0xMjswODozMjoyMyBBTTsxOzExMTE="/>
<attribute name="edited" value="eXV2bGlhbjtDT1NNT1M7MjAyNi0wMy0xMjsxMDoxNDoyMCBBTTsxOzI2MDU="/>
</attributes>
<function name="Main" type="None" variable="">
<parameters/>
<body>
<declare name="targetHarga, angkaTebakan, percobaan, diff" type="Integer" array="False" size=""/>
<declare name="diffPersen" type="Real" array="False" size=""/>
<declare name="inputTebakan, ket" type="String" array="False" size=""/>
<declare name="jawabanBenar" type="Boolean" array="False" size=""/>
<assign variable="targetHarga" expression="0"/>
<while expression="targetHarga &lt; 10000">
<assign variable="targetHarga" expression="Random(200001)"/>
</while>
<output expression="&quot;DEBUG: targetHarga = &quot; &amp; targetHarga" newline="True"/>
<assign variable="percobaan" expression="0"/>
<assign variable="jawabanBenar" expression="false"/>
<output expression="&quot;Tebak harga barang (Rp 10.000 - Rp 200.000).&quot;" newline="True"/>
<output expression="&quot;Ketik nyerah untuk berhenti.&quot;" newline="True"/>
<while expression="not jawabanBenar and percobaan &lt; 12">
<output expression="&quot;Tebakan &quot; &amp; (percobaan + 1) &amp; &quot;/12&quot;" newline="True"/>
<output expression="&quot;Masukkan tebakan anda:&quot;" newline="True"/>
<input variable="inputTebakan"/>
<if expression="inputTebakan = &quot;nyerah&quot;">
<then>
<output expression="&quot;Jawaban yang benar: Rp &quot; &amp; targetHarga" newline="True"/>
<assign variable="percobaan" expression="12"/>
</then>
<else>
<assign variable="angkaTebakan" expression="ToInteger(inputTebakan)"/>
<if expression="angkaTebakan &lt; 10000 or angkaTebakan &gt; 200000">
<then>
<output expression="&quot;Input tidak valid! Masukkan angka antara 10000 sampai 200000.&quot;" newline="True"/>
</then>
<else>
<assign variable="percobaan" expression="percobaan + 1"/>
<if expression="angkaTebakan = targetHarga">
<then>
<output expression="&quot;Selamat! Tebakan Anda benar!&quot;" newline="True"/>
<assign variable="jawabanBenar" expression="true"/>
</then>
<else>
<assign variable="diffPersen" expression="((angkaTebakan - targetHarga) * 100.0) / targetHarga"/>
<if expression="diffPersen &gt; 0">
<then>
<assign variable="ket" expression="&quot;kelebihan &quot; &amp; diffPersen"/>
</then>
<else>
<assign variable="ket" expression="&quot;kekurangan &quot; &amp; Abs(diffPersen)"/>
</else>
</if>
<if expression="Abs(diffPersen) &lt;= 5">
<then>
<output expression="&quot;PANAS! (Jawabanmu &quot; &amp; ket &amp; &quot;%)&quot;" newline="True"/>
</then>
<else>
<if expression="Abs(diffPersen) &lt;= 15">
<then>
<output expression="&quot;HANGAT! (Jawabanmu &quot; &amp; ket &amp; &quot;%)&quot;" newline="True"/>
</then>
<else>
<output expression="&quot;DINGIN! (Jawabanmu &quot; &amp; ket &amp; &quot;%)&quot;" newline="True"/>
</else>
</if>
</else>
</if>
</else>
</if>
</else>
</if>
</else>
</if>
</while>
<if expression="not jawabanBenar and percobaan = 12 and inputTebakan != &quot;nyerah&quot;">
<then>
<output expression="&quot;Kesempatan habis! Jawaban yang benar: &quot; &amp; targetHarga" newline="True"/>
</then>
<else/>
</if>
</body>
</function>
</flowgorithm>