Home
Recent Q&A
Java
Cloud
JavaScript
Python
SQL
PHP
HTML
C++
Data Science
DBMS
Devops
Hadoop
Machine Learning
Azure
Blockchain
Devops
Ask a Question
How to round off numbers in java in 2 mins
Home
JAVA
How to round off numbers in java in 2 mins
0
votes
asked
Oct 10, 2020
in
JAVA
by
Robindeniel
How to round off numbers in java?
#round-off-numbers
#java-round-off-number
Java-questions-answers
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Oct 10, 2020
by
SakshiSharma
"import java.lang.Math; // Needed to use Math.round()
class Program {
public static void main( String args[] ) {
double num1 = 74.65;
System.out.println(Math.round(num1));
float num2 = 1337.345523f;
System.out.println(Math.round(num2));
}
}"
Your comment on this answer:
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Related questions
0
votes
Q: How to round up to 2 decimal places in java?
asked
Nov 15, 2020
in
JAVA
by
rajeshsharma
#java-error
#java-decimal-place
Java-questions-answers
0
votes
Q: Learn quickly how to uninstall java in 5 mins?
asked
Oct 10, 2020
in
JAVA
by
Robindeniel
#uninstall-java
#java-uninstall
Java-questions-answers
+2
votes
Q: What will be the output of Round(3.7) and Ceil(3.7) in Java?
asked
May 31, 2020
in
JAVA
by
SakshiSharma
#java-round
#java-ceil
3
7
Java-questions-answers
0
votes
Q: Write a program to convert decimal numbers to octal.
asked
Oct 24, 2020
in
JAVA
by
sharadyadav1986
#convert-decimal-to-octal
#decimal-to-octal
Java-questions-answers
0
votes
Q: Write a program to convert decimal numbers to binary.
asked
Oct 23, 2020
in
JAVA
by
rahuljain1
#decimal-to-binary-program
#program-decimal-to-binary
Java-questions-answers
+2
votes
Q: Which of the following is the correct lambda expression, which adds two numbers and returns their sum?
asked
Feb 8, 2020
in
JAVA
by
rahuljain1
#java-lambda-expression
Java-questions-answers
0
votes
Q: Can we use random numbers in the hashcode() method?
asked
Jan 27, 2020
in
JAVA
by
rahuljain1
#java-hashcode
Java-questions-answers
0
votes
Q: Which one would be easy to write? synchronization code for 10 threads or 2 threads?
asked
Jan 24, 2020
in
JAVA
by
rahuljain1
#java-synchronization
Java-questions-answers
+2
votes
Q: How to Print Range Between random number 2 row and 3 cols integers random numbers
asked
Jul 4, 2021
in
NumPy
by
sharadyadav1986
print-range
0
votes
Q: Which of the following type of JDBC driver, is also called Type 2 JDBC driver?
asked
May 21, 2020
in
JAVA
by
GeorgeBell
#java
Java-questions-answers
...