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

Which are mixtures? Check all that apply.
Martin runs 100 meters in 15 seconds. What is the equation for d, the distance in meters that Martin covers per second? A. 15 + d = 100 B. 100 + d = 15 C. d
I need help please?!!!!):
In how many ways can a student arrange 6 textbooks on a locker shelf that can hold 4 books at a time
What is the role of a control group in any experiment
When solving the equation 12x^2 - 7x = 6-2(x^2 - 1). Evan wrote 12x^2 - 7x = 6 - 2x^2 + 2 as his first step. Which propertyjustifies this step?a. subtraction pr
Vlad spent 20 minutes on his history homework and then completely solved x math problems that each took 2 minutes to complete
Define proportional representation: Define equal representation: Who was the father of the US Constitution? What is the main purpose of the US Constitution? Wha
which work of art features a series of biblical events ?
please help me with the correct answer!! thanks!