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

A molecule is made up of two or more chemically bonded atoms. true or false
How can you use models to explain why 3.1=3.10?
What is a synonym for doctrine
Find the average of the following salaries: $52,500.00, $53,500.00 $55,500.00, $56,500.00
How many centimeters are in an inch?
Many men are reluctant to have a vasectomy because of A. the fear of decreased sexual performance. B. the financial cost. C. the permanency. D. the major su
The average speeds of gas molecules in cylinders A, B, C, and D are 0.01 m/s, 0.005 m/s, 0.1 m/s, and 0.5 m/s, respectively. Which cylinder contains gas that is
write two monomials whose greatest common factor is 4m
The cross products of a proportion are never equal. True or false?
According to the hardy-Weinberg principle,which of the following is most likely to disrupt genetic equilibrium