Let a be any floating point number:
float a = 13.1234567;
then I get a decimal places length from standard input:
import java.util.Scanner;
Scanner sc = new Scanner(System.in);
int decLen = sc.nextInt();
How do I print 'a' with 'decLen' decimal places after the point? I need to print for
decLen = 3:
13.123
decLen = 6:
13.123456
decLen = 0:
13
Is there in the Java libaries any formatting method capable of this kind of tasks?