Can anybody solve the query for me please
In June of 2005, Sammy puts $ 1,024 into a savings account and, each month thereafter, plans to deposit only half of what he saved in the previous month. Using a single for loop, write a program that will show that he will have deposited $ 2,047.50 into his account by the end of May 2006. Express your output as a dollar amount, with two decimal places.
Thanks
Dev
hi the solution for your problem is:
SQL> declare
2 present number(7,2):=1024.00;
3 inc number(10,2);
4 final number(10,2);
5 mon number;
6 begin
7 final:=1024.00;
8 mon := months_between(to_date('may-06','mon-yy'),to_date('june-05','mon-yy'));
9 for i in 1..mon loop
10 present :=present/2;
11 final := final+present;
12 dbms_output.put_line('savings in the month of '||i||'='||present);
13 end loop;
14 dbms_output.put_line('final amount is : '||ltrim(to_char(final,'L99G999D99MI')));
15 end;
16 /
savings in the month of 1=512
savings in the month of 2=256
savings in the month of 3=128
savings in the month of 4=64
savings in the month of 5=32
savings in the month of 6=16
savings in the month of 7=8
savings in the month of 8=4
savings in the month of 9=2
savings in the month of 10=1
savings in the month of 11=.5
final amount is : $2,047.50
PL/SQL procedure successfully completed.
hope this helped you. if there are any issues let me know