Nice to meet you.
About the calculation result of the decimal point.
This is what you get when you type:
If i enter 180 ← 1.80 on the input screen, it will be 0 with an error
62
Result screen
180.0
62
BMI 0.0018717546190073662
.
As a result I want to do
Input screen 1.80
62
Result screen
1.80
62
BMI 18.7175 ...
I would like you to tell me the process to achieve this result.
Please take care.
I'd like advice too,
double num1 = 0;
double num2 = 0;
double resultNum;
try {
num1 = Integer.parseInt (request.getParameter ("num1"));
num2 = Integer.parseInt (request.getParameter ("num2"));
resultNum = num2/(num1 * num1);
BigDecimal bd = new BigDecimal (resultNum);
bd = bd.setScale (1, RoundingMode.HALF_UP);
} catch (NumberFormatException e) {
resultNum = 0;
}
request.setAttribute ("num1", num1);
request.setAttribute ("num2", (int) num2);
request.setAttribute ("resultNum", resultNum);
-
Answer # 1
Related articles
- java main method not found using eclipse
- java - about flatmap method
- pytorch mean squared error calculation method
- java - method using graphics class created in another file cannot be used in main method of main class
- java - send method return value to servlet with jsp
- when i run the c language, i get a "fixed decimal point exception"
- java - to create a method and call it from another class
- java - i want to get the date and time continuously by calculation without using sleep or timer
- calculation method by python groupby
- java calculation count and result
- method of confirming equivalence of different types in java
- java instance generation method
- java - program that creates and uses api for age calculation (asynchronous)
- java - i don't know the cause of the error "this method must return a result of type ○○○○"
- java - i want to use the return value of one method in another
- java - about the stringvalueof () method
- java - equals method
- java - functional interface and calculation processing
- java - i want to create a method that gets and returns the name corresponding to the number
- what happens when multiple java users call the same method
- java : I want to get the file name and pass it to the Servlet class.
- java - i get a message saying that i can't forward after committing the response
- about dynamic table design policy in jsp-java servlet-db linkage
- java - tiles are not recognized under struts 25 environment
- java - on the login screen, if the login is successful, i want to move to another jsp page
- how to implement "like function" in servlet, java, postgresql?
- java - how to display background image in jsp
- java - i want to leave the initial value of the radio button unselected
- i want to pass a character string from java servlet to jsp and display it
- java - i don't know how to get log4j running in my application
"1.80" is not an integer, so Integer.parseInt that converts to an integer is not possible.
Use Double.parseDouble instead.