Post Reply 
Simple Interest
05-17-2015, 03:10 PM (This post was last modified: 05-17-2015 03:12 PM by salvomic.)
Post: #1
Simple Interest
hi all,
to try DDAYS, I'm making a program to calc simple interest.
This program works but has two problems related to DDAYS:
first: I must calc the interest both for actual period and for financial, but DDAYS (as it is) calculates only for actual period (365 days and month of various duration), not for financial year (360 days and months all of 30 days)...
Any help appreciated.

Second problem is related to input: I used dropdown menus for days and months (not for year), but if months menu has 12 items, also if days menu has 31, it shows always only 12 also: there is a limit, using more than one dropdown menu or is the problem different?

A dirty solution would be use a textbook instead, but I'm curious about that problem with dropdown...

Please, help Smile

Salvo

Code:

fin();
act();
calcd();
smenu();

EXPORT simple_interest()
BEGIN
smenu();
END;

fin(n)
BEGIN
local mesg, r, pv, I;
input ({n,r, pv}, "Interest financial year", {"n","i", "PV"}, 
{"Period (day)", "rate", "present value"},{n,0, 0} );
I:= (n/360)*pv*r/100;
mesg:= Eval(pv) +" for " + EVAL(n) + " days at " + EVAL(r) + "%" +
"
Interest (360 days) = " + EVAL(I) +
"
Total (PV + I) = " + EVAL(I+pv) + "";
PRINT;
PRINT (mesg);
WAIT (0);
smenu();
RETURN {I, I+pv};
END;

act(n)
BEGIN
local mesg, r, pv, I;
input ({n,r, pv}, "Interest financial year", {"n","i", "PV"}, 
{"Period (day)", "rate", "present value"},{n,0, 0} );
I:= (n/365)*pv*r/100;
mesg:= Eval(pv) +" for " + EVAL(n) + " days at " + EVAL(r) + "%" +
"
Interest (365 days) = " + EVAL(I) +
"
Total (PV + I) = " + EVAL(I+pv) + "";
PRINT;
PRINT (mesg);
WAIT (0);
smenu();
RETURN {I, I+pv};
END;

calcd()
BEGIN
local mesg, days1, days2, n, dd1;
local dd2, mm1, mm2, yy1, yy2;

input ({ {dd1,{"1","2","3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"},
{15,15,1}}, 
{mm1,{"1","2","3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, {40,15,1}}, 
{yy1,[0],{70,20,1}},
{dd2,{"1","2","3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"},
{15,15,3}}, 
{mm2,{"1","2","3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, {40,15,3}}, 
{yy2,[0],{70,20,3}} 
}, 
"Calc days (actual)", {"d1", "m1", "y1", "d2", "m2", "y2"}, 
{"Day 1", "Month 1", "Year 1", "Day 2", "Month 2", "Year 2"}, 
{0, 0, 0, 0, 0, 0 }, {0, 0, 2015, 0, 0, 2015} );
dd1:=EVAL(dd1); mm1:=EVAL(mm1);
dd2:=EVAL(dd2); mm2:=EVAL(mm2);
yy1:=EVAL(yy1); yy2:=EVAL(yy2);
days1 := yy1+mm1/100+dd1/10000;
days2 := yy2+mm2/100+dd2/10000;
n:= DDAYS(days1, days2);
mesg:="Days n = " + EVAL(n) +

from " + EVAL(dd1) + " - " + EVAL(mm1) + " - " + EVAL(yy1) +
" to " + EVAL(dd2) + " - " + EVAL(mm2) + " - " + EVAL(yy2) + 
"";
PRINT;
PRINT (mesg);
WAIT(0);
act(n);
END;

smenu()
BEGIN
local ch;
CHOOSE(ch,"Mode","Finacial year","Actual year", "Calc Date (actual)", "Quit");
CASE
IF ch==1 THEN fin(0); END;
IF ch==2 THEN act(0); END;
IF ch==3 THEN calcd(); END;
if ch==4 THEN return; END;
DEFAULT
END; //case
END;

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Simple Interest - salvomic - 05-17-2015 03:10 PM
RE: Simple Interest - salvomic - 05-17-2015, 04:40 PM
RE: Simple Interest - salvomic - 05-17-2015, 07:48 PM
RE: Simple Interest - salvomic - 05-18-2015, 01:59 PM



User(s) browsing this thread: 1 Guest(s)