formatting a string in java
<p>I would like to know how to provide a formatting capabilities that enable the user  to specify the number of digits of precision to the right of a decimal number. so instead of using the classical formatting .2f or .3f etc.. I want the user to be able to enter the precision of the decimal number.</p>

<p>i have a code written as follows</p>

<pre><code>Scanner input = new Scanner (System.in);
int precision = input.nextInt();

addNumbers.numberRepresentaiton(int precision);
</code></pre>

<p>The method is defined as below</p>

<pre><code>private String numberRepresentation(int precision)
{
    return String.format("%.precisionf", add);
}
</code></pre>

<p>executing the above results in conversion formatting error.
Thank you for your time.</p>
