roszettadean4548 roszettadean4548
  • 04-04-2020
  • Computers and Technology
contestada

1. Write code that prints the square root of the value in the variable num rounded to 4 decimal places. Assume that num already has a value and that the math module has been imported.

Respuesta :

ijeggs
ijeggs ijeggs
  • 06-04-2020

Answer:

System.out.printf("The square root is %.4f\n",sqrt);

Explanation:

In Java programming language using the print format method of System.out One can specify the the number of decimal places. In this case to 4 decimal places.

See a complete code snippet below

public class num1 {

   public static void main(String[] args) {

       double num =5;

       double sqrt = Math.sqrt(5);

       System.out.printf("The square root is $%.4f\n",sqrt);

   }

}

Answer Link

Otras preguntas

how are factors related to prime numbers
The "Great Three" West African empires were Ghana, Mali, and .
Karangan kepentingan memilih rakan sebaya yang baik
What is the function of the contractile vacuole in plant-like protists?
Yuri has a rope 12m long. he cuts it into pieces that are each 2m long. what fraction of the rope is one piece
Consider a rabbit, which of the following is true regarding its DNA? A) All of its cells contain the same DNA. B) Each cell type contains its own unique DNA. C
A circle has a radius of 2.5 centimeters and a central angle AOB that measures 90°. What is the area of sector AOB? Use 3.14 for pi and round your answer to the
What is genotype for a recessive trait found on the female chromosome? Yh Xh XH YH
reduce 18/32 to lowest terms
What was the length of the president's term of office in the Confederate States of America? a. two years b. six years c. three years d. four years