|
| 1 | +from turtle import delay |
| 2 | +from modul import * |
| 3 | +import time |
| 4 | + |
| 5 | +# assume value is a decimal |
| 6 | +def transform_to_rupiah_format(value): |
| 7 | + str_value = str(value) |
| 8 | + separate_decimal = str_value.split(".") |
| 9 | + after_decimal = separate_decimal[0] |
| 10 | + before_decimal = separate_decimal[1] |
| 11 | + |
| 12 | + reverse = after_decimal[::-1] |
| 13 | + temp_reverse_value = "" |
| 14 | + |
| 15 | + for index, val in enumerate(reverse): |
| 16 | + if (index + 1) % 3 == 0 and index + 1 != len(reverse): |
| 17 | + temp_reverse_value = temp_reverse_value + val + "." |
| 18 | + else: |
| 19 | + temp_reverse_value = temp_reverse_value + val |
| 20 | + |
| 21 | + temp_result = temp_reverse_value[::-1] |
| 22 | + |
| 23 | + return "Rp " + temp_result + ",0" + before_decimal |
| 24 | + |
| 25 | + |
| 26 | +def formatrupiah(uang): |
| 27 | + y = str(uang) |
| 28 | + if len(y) <= 3: |
| 29 | + return 'Rp ' + y |
| 30 | + else: |
| 31 | + p = y[-3:] |
| 32 | + q = y[:-3] |
| 33 | + return formatrupiah(q) + '.' + p |
| 34 | + |
| 35 | + |
| 36 | +# default budgeting percentage (single) |
| 37 | +living = 0.30 |
| 38 | +playing = 0.20 |
| 39 | +saving = 0.50 |
| 40 | + |
| 41 | +# # default budgeting percentage (married) |
| 42 | +# living = 0.30 |
| 43 | +# playing = 0.15 |
| 44 | +# saving = 0.55 |
| 45 | + |
| 46 | +budget = int(input('Masukkan pemasukan anda: ')) |
| 47 | + |
| 48 | + |
| 49 | +# tiap tiap kategorinya |
| 50 | +percent_living = living * 100 |
| 51 | +percent_playing = playing * 100 |
| 52 | +percent_saving = saving * 100 |
| 53 | +percentage = [percent_playing, percent_living, percent_saving] |
| 54 | +sum = 00.0 |
| 55 | +percent_budget = (living + playing + saving)*100 |
| 56 | + |
| 57 | +budget_living = budget * living |
| 58 | +budget_playing = budget * playing |
| 59 | +budgett_saving = budget * saving |
| 60 | + |
| 61 | +print('========================================================') |
| 62 | +for x in percentage: |
| 63 | + print('Checking Persen Budgeting '+'{}'.format(sum)+' %'+' (Checking)') |
| 64 | + time.sleep(2) |
| 65 | + sum += x |
| 66 | + |
| 67 | +print('Checking Persen Budgeting '+'{}'.format(percent_budget)+'%'+' (Done)') |
| 68 | +time.sleep(2) |
| 69 | +print('Budgeting anda adalah sebesar {}'.format(formatrupiah(budget))+',00') |
| 70 | +print('Pemasukan anda untuk kebutuhan hidup adalah\t: {}'.format( |
| 71 | + transform_to_rupiah_format(budget_living))) |
| 72 | + |
| 73 | +print('Pemasukan anda untuk kegiatan adalah\t\t: {}'.format( |
| 74 | + transform_to_rupiah_format(budget_playing))) |
| 75 | +print('Pemasukan anda untuk tabungan adalah\t\t: {}'.format( |
| 76 | + transform_to_rupiah_format(budgett_saving))) |
| 77 | +print('========================================================') |
0 commit comments