FineCalc — это полностью автономный графический финансовый калькулятор.
Что делает: Считает сложные проценты по вкладам (итоговый капитал и чистую прибыль) или параметры ипотеки (ежемесячный аннуитетный платеж, общую сумму выплат и величину переплаты банку), выводя результаты в виде аккуратной карточки и цветной диаграммы долей.
Как запускается в GUI: Программа открывает собственное независимое графическое окно. Все кнопки, текстовые поля и интерактивный ввод чисел с клавиатуры (с отображением курсора и стиранием знаков) отрисовываются нативно встроенными командами Yabasic без использования консольной строки input.
Скриншоты работы программы:
Листинг:
Что делает: Считает сложные проценты по вкладам (итоговый капитал и чистую прибыль) или параметры ипотеки (ежемесячный аннуитетный платеж, общую сумму выплат и величину переплаты банку), выводя результаты в виде аккуратной карточки и цветной диаграммы долей.
Как запускается в GUI: Программа открывает собственное независимое графическое окно. Все кнопки, текстовые поля и интерактивный ввод чисел с клавиатуры (с отображением курсора и стиранием знаков) отрисовываются нативно встроенными командами Yabasic без использования консольной строки input.
Скриншоты работы программы:
Листинг:
Код: Выделить всё
// =============================================
// Финансовый калькулятор (полный GUI, без консоли)
// Yabasic 2.91
// =============================================
sub input_number(x, y, prompt$)
local buffer$, char$, finished, val_num
buffer$ = ""
finished = false
// Очищаем буфер клавиатуры от возможных "застрявших" клавиш
while inkey$(0.01) <> "" : wend
// Рамка и подпись
color 255, 255, 255
fill rectangle x, y, x + 250, y + 30
color 180, 180, 180
rectangle x, y, x + 250, y + 30
color 45, 55, 72
text x, y - 15, prompt$, "lc", "swiss12"
while not finished
// Отображаем текущий буфер с курсором
color 255, 255, 255
fill rectangle x + 5, y + 3, x + 245, y + 27
color 0, 0, 0
text x + 10, y + 10, buffer$ + "_", "lc", "swiss14"
// Блокирующее ожидание клавиши
char$ = inkey$
// Цифра или точка
if (char$ >= "0" and char$ <= "9") or char$ = "." then
buffer$ = buffer$ + char$
// Backspace (и по имени, и по коду)
elsif char$ = "backspace" or char$ = chr$(8) then
if len(buffer$) > 0 then
buffer$ = left$(buffer$, len(buffer$)-1)
endif
// Enter (и по имени, и по коду)
elsif char$ = "enter" or char$ = chr$(13) then
if len(buffer$) > 0 then
finished = true
else
beep // сигнал: нельзя оставить поле пустым
endif
endif
wend
// Убираем курсор и показываем окончательное значение
color 255, 255, 255
fill rectangle x + 5, y + 3, x + 245, y + 27
color 0, 0, 0
text x + 10, y + 10, buffer$, "lc", "swiss14"
return val(buffer$)
end sub
sub draw_button(x, y, w, h, label$)
color 66, 133, 244
fill rectangle x, y, x + w, y + h
color 255, 255, 255
text x + w/2, y + h/2, label$, "cc", "swiss14b"
end sub
sub inside(x, y, w, h)
if mousex >= x and mousex <= x + w and mousey >= y and mousey <= y + h then
return true
endif
return false
end sub
// ========== Главная программа ==========
win_w = 650
win_h = 450
open window win_w, win_h
clear screen // обязательно перед любым inkey$
backcolor 240, 244, 248
clear window
label restart
clear screen // нужно после каждого возврата
clear window
color 26, 54, 93
text 325, 40, "FINANCIAL CALCULATOR", "cc", "swiss24b"
draw_button(175, 120, 300, 60, "1. Compound Interest")
draw_button(175, 220, 300, 60, "2. Mortgage Calculator")
draw_button(250, 360, 150, 45, "Exit")
mode = 0
while mode = 0
k$ = inkey$(0.1)
if left$(k$, 2) = "MB" then
b = mouseb(k$)
x = mousex(k$)
y = mousey(k$)
if b = 1 then
if inside(175, 120, 300, 60) then
mode = 1
endif
if inside(175, 220, 300, 60) then
mode = 2
endif
if inside(250, 360, 150, 45) then
close window
end
endif
endif
endif
wend
clear window
color 26, 54, 93
if mode = 1 then
text 325, 30, "COMPOUND INTEREST", "cc", "swiss22b"
else
text 325, 30, "MORTGAGE CALCULATOR", "cc", "swiss22b"
endif
if mode = 1 then
principal = input_number(200, 90, "Initial Capital (rub):")
rate = input_number(200, 150, "Annual Rate (%):")
years = input_number(200, 210, "Term (years):")
else
property_value = input_number(200, 90, "Property Value (rub):")
down_payment = input_number(200, 150, "Down Payment (rub):")
rate = input_number(200, 210, "Annual Rate (%):")
years = input_number(200, 270, "Term (years):")
principal = property_value - down_payment
endif
if principal <= 0 or rate <= 0 or years <= 0 then
color 200, 0, 0
text 325, 380, "Invalid values! Click anywhere to retry.", "cc", "swiss14"
inkey$
goto restart
endif
clear window
color 255, 255, 255
fill rectangle 40, 80, 610, 390
color 218, 226, 236
rectangle 40, 80, 610, 390
if mode = 1 then
total = principal * ((1 + rate / 100) ^ years)
profit = total - principal
color 26, 54, 93
text 325, 30, "RESULTS: COMPOUND INTEREST", "cc", "swiss22b"
color 45, 55, 72
text 60, 110, "Initial Capital: " + str$(principal, "###,###,###", " ,") + " rub.", "lc", "swiss14"
text 60, 140, "Annual Rate: " + str$(rate, "%.2f") + "%", "lc", "swiss14"
text 60, 170, "Term: " + str$(years) + " years", "lc", "swiss14"
color 47, 133, 90
text 60, 220, "Total Accumulation: " + str$(total, "###,###,###", " ,") + " rub.", "lc", "swiss16b"
text 60, 250, "Net Profit: " + str$(profit, "###,###,###", " ,") + " rub.", "lc", "swiss16b"
color 226, 232, 240
fill rectangle 60, 310, 590, 340
color 72, 187, 120
fill rectangle 60, 310, 60 + (530 * (principal / total)), 340
color 45, 55, 72
text 60, 365, "Green: Net Profit share in final amount", "lc", "swiss11"
else
m_rate = (rate / 100) / 12
months = years * 12
if months = 0 then
months = 1
endif
k = (m_rate * ((1 + m_rate) ^ months)) / (((1 + m_rate) ^ months) - 1)
monthly_payment = principal * k
total_payment = monthly_payment * months
overpayment = total_payment - principal
color 26, 54, 93
text 325, 30, "RESULTS: MORTGAGE", "cc", "swiss22b"
color 45, 55, 72
text 60, 100, "Loan Amount: " + str$(principal, "###,###,###", " ,") + " rub.", "lc", "swiss14"
text 60, 125, "Down Payment: " + str$(down_payment, "###,###,###", " ,") + " rub.", "lc", "swiss14"
text 60, 150, "Term: " + str$(years) + " years (" + str$(months) + " mos)", "lc", "swiss14"
text 60, 175, "Rate: " + str$(rate, "%.2f") + "%", "lc", "swiss14"
color 229, 62, 62
text 60, 220, "Monthly Payment: " + str$(monthly_payment, "###,###,###", " ,") + " rub./mo.", "lc", "swiss16b"
color 45, 55, 72
text 60, 250, "Total Payout: " + str$(total_payment, "###,###,###", " ,") + " rub.", "lc", "swiss14"
text 60, 280, "Overpayment: " + str$(overpayment, "###,###,###", " ,") + " rub.", "lc", "swiss14"
color 239, 108, 0
fill rectangle 60, 330, 590, 355
color 33, 150, 243
fill rectangle 60, 330, 60 + (530 * (principal / total_payment)), 355
color 100, 100, 100
text 60, 375, "Blue - Loan Principal, Orange - Bank Interest", "lc", "swiss11"
endif
draw_button(200, 410, 100, 35, "Back")
draw_button(350, 410, 100, 35, "Exit")
while true
k$ = inkey$(0.1)
if left$(k$, 2) = "MB" then
b = mouseb(k$)
x = mousex(k$)
y = mousey(k$)
if b = 1 then
if inside(200, 410, 100, 35) then
goto restart
endif
if inside(350, 410, 100, 35) then
close window
end
endif
endif
endif
wend