The Java method Math.round can be used to round numbers. Which of the following code fragments converts a floating-point number to the nearest integer?
A) double f = 4.65;
int n = (int) Math.round(100 * f) ;
B) double f = 4.65;
int n = (int) Math.round(f) ;
C) double f = 4.65;
int n = Math.round(f) ;
D) double f = 4.65;
int n = (int) f;
Correct Answer:
Verified
Q24: What is the error in the following
Q25: Consider this method comment. Which of the
Q26: What is the syntax error in the
Q27: In a vehicle mileage application, you enter
Q28: What is the error in the following
Q30: In an accounting application, you discover several
Q31: What is the output of the following
Q32: Suppose you need to write a method
Q33: Which of the following options represents the
Q34: Which of the following is true about
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents