Skip to content

Commit 3d10b33

Browse files
author
Dhananjay Nagargoje
committed
zerodha verasity lesson 1
1 parent 8f1fe23 commit 3d10b33

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: src/main/java/algorithms/trading/WithoutInvesting.java

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package algorithms.trading;
22

33
import java.text.DecimalFormat;
4+
import java.text.NumberFormat;
45

56
public class WithoutInvesting {
67
public static void main(String[] args) {
@@ -13,11 +14,16 @@ public static void main(String[] args) {
1314

1415
int retirementAmount = 0;
1516
int investedRetirementAmount = 0;
17+
NumberFormat nf = DecimalFormat.getInstance();
18+
System.out.printf("%8s %10s %10s %10s\n","Year","Income","Expense","Cash Retained");
1619
for (int i = 2; i <= 30; i++) {
1720

1821
save*=12;
1922
retirementAmount += save;
2023
investedRetirementAmount += save;
24+
System.out.printf("%8d %10s %10s %10s",
25+
i,nf.format(sal*12),nf.format(sal*12-save),nf.format(retirementAmount));
26+
System.out.println();
2127
// System.out.println("salary : " + sal);
2228
// System.out.println("save : " + save);
2329
sal = sal + ((sal*inc)/100);
@@ -26,8 +32,10 @@ public static void main(String[] args) {
2632
//if he invests in some schemenwith 12 % return.
2733
investedRetirementAmount+=(investedRetirementAmount*12/100);
2834

35+
2936
}
3037

38+
System.out.println();
3139
System.out.println("Man saves "+ DecimalFormat.getInstance().format( retirementAmount) + " if he does not invest anywhere.");
3240
System.out.println("Man saves "+ DecimalFormat.getInstance().format(investedRetirementAmount) + " if he invests at 12 % per annum.");
3341
}

0 commit comments

Comments
 (0)