My application deals with prices, I am facing a small problem here. I will explain it clearly in steps.

Following are my inputs and OutPut should be.


  input  1.01  =  output 1 
  
  input 1.748  = output 1.75
  
  input 1.98  =output 2
  
  input 1.49 = output 1.5
  
  input 20.0 = output 2


0

I have used the following code but I can't achieve it

    double calc = 1.98;
            DecimalFormat df = new DecimalFormat("#.##");  
            calc = Double.valueOf(df.format(calc));
            System.out.println(String.valueOf(calc).replaceAll("([0-9])\\.0+([^0-9]|$)", "$1$2"));

::&gt; output is 1.98 which should be 2

double calc = 20.0;
        DecimalFormat df = new DecimalFormat("#.#");  
        calc = Double.valueOf(df.format(calc));
        System.out.println(String.valueOf(calc).replaceAll("([0-9])\\.0+([^0-9]|$)", "$1$2"));

 ::&gt; output is 20 this is correct for me.

double calc = 2.01;
        DecimalFormat df = new DecimalFormat("#.##");  
        calc = Double.valueOf(df.format(calc));
        System.out.println(String.valueOf(calc).replaceAll("([0-9])\\.0+([^0-9]|$)", "$1$2"));

::&gt; output is 2.01  Which should be 2.


following code which I have tried.


Question: Adding variables to the model one by one, or at the same time
Answer: This is a habit that stems from linear regression, where this sequence of models can be interpreted as ways of estimating indirect effects. Unfortunately this trick does not generalize to non-linear models, like logistic regression (e.g. Buis 2010). Still the habit persists, as you have observed. Unless you are interested in direct an indirect effects, I would just avoid all the complexities involved with comparing non-linear models and just report one model. If direct and indirect effects are of interest then you can choose between different methods, some references are given below:

M.L. Buis (2010). Direct and indirect effects in a logit model. The Stata Journal, 10(1), pp. 11-29.
http://www.stata-journal.com/article.html?article=st0182 (free)

Hicks, R. and D. Tingley (2011). Causal mediation analysis. The Stata Journal 11(4), 605-619.
http://www.stata-journal.com/article.html?article=st0243

Kohler, U., K. B. Karlson, and A. Holm (2011). Comparing coefficients of nested nonlinear probability models. The Stata Journal 11(3), 420-438. 
http://www.stata-journal.com/article.html?article=st0236 

Sinning, M., M. Hahn, and T. K. Bauer (2008). The Blinder-Oaxaca decomposition for nonlinear regression models. The Stata Journal 8(4), 480-492.
http://www.stata-journal.com/article.html?article=st0152 (free)