I am having difficulty of creating a method to display first n digits of a number when ‘n’ is determined by the user.
For example, user inputs an integer ‘1234567’ and a number of digits to display ‘3’. The method then outputs ‘123’.
I have an idea how to display the first digit:
long number = 52345678;
long prefix = number /= (int) (Math.pow(10.0, Math.floor(Math.log10(number))));
But I seem not being able to figure out how to display a user defined first n digits.
Thank you!
If you want a number: