File tree Expand file tree Collapse file tree
core-java/src/main/java/com/baeldung/maths Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,30 +13,37 @@ public static void main(String[] args) {
1313 System .out .println ("b = " + b );
1414 System .out .println ("c = " + c );
1515
16- double ab = a + b ;
17- System .out .println ("a + b = " + ab );
16+ double sum_ab = a + b ;
17+ System .out .println ("a + b = " + sum_ab );
1818
1919 double abc = a + b + c ;
2020 System .out .println ("a + b + c = " + abc );
2121
22- double ac = a + c ;
23- System .out .println ("a + c = " + ac );
22+ double ab_c = sum_ab + c ;
23+ System .out .println ("ab + c = " + ab_c );
24+
25+ double sum_ac = a + c ;
26+ System .out .println ("a + c = " + sum_ac );
2427
2528 double acb = a + c + b ;
2629 System .out .println ("a + c + b = " + acb );
2730
28- double ac_b = ac + b ;
31+ double ac_b = sum_ac + b ;
2932 System .out .println ("ac + b = " + ac_b );
3033
34+ double ab = 18.1 ;
35+ double ac = 34.67 ;
36+ double sum_ab_c = ab + c ;
37+ double sum_ac_b = ac + b ;
38+ System .out .println ("ab + c = " + sum_ab_c );
39+ System .out .println ("ac + b = " + sum_ac_b );
40+
3141 BigDecimal d = new BigDecimal (String .valueOf (a ));
3242 BigDecimal e = new BigDecimal (String .valueOf (b ));
3343 BigDecimal f = new BigDecimal (String .valueOf (c ));
3444
35- BigDecimal def ;
36- BigDecimal dfe ;
37-
38- def = d .add (e ).add (f );
39- dfe = d .add (f ).add (e );
45+ BigDecimal def = d .add (e ).add (f );
46+ BigDecimal dfe = d .add (f ).add (e );
4047
4148 System .out .println ("d + e + f = " + def );
4249 System .out .println ("d + f + e = " + dfe );
You can’t perform that action at this time.
0 commit comments