System.out.println("Percentage (90): " + (_leftBranch.getHeight() / 100) * 90 + " Height: " + _leftBranch.getHeight());
Gives the output:
Percentage (90): 270 Height: 359
When infact it should be 323.1.
Can anyone tell me what’s going on here?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because the calculations are done in integer type.
Put 100.0 and 90.0 instead of 100 and 90
The first part of calculation results in 3.59. But it only considers integer part which is 3 thus the result 270