1

Ex i input 10.98 and i want to display .98 but the answer on my code is 0.98. Can someone help me? Thanks

Double numOne,numTwo;

System.out.print("Enter a decimal num: ");
numOne= Double.parseDouble(br.readLine());


numTwo = numOne - Math.floor(numOne) ;

System.out.printf("%.2f", numTwo);
lnosmas
  • 21
  • 2

1 Answers1

0

use

    System.out.println( String.valueOf(result).substring( 1, String.valueOf(result).length() - 1) );

instead of last line

Arphile
  • 841
  • 6
  • 18