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

What environmental disaster can be attributed to overpopulation over use of resources by humans
If a gas is heated from 263 to 298 k, the volume is 24 l to 35 l at 1.00 atm pressure. what is the final pressure?
What is the total number of electrons in all s orbitals of a neutral atom of phosphorus?
the height of a building is 35.5 meters. what is the height of the building in centimeters
Identify the transformation of the geometric figure performed in the graph.
The macronutrients are carbohydrates protein and fat true or false
Mr bartley is taking the theater club on a field trip he wrote the the folowing function for the school treasure 52(25+2)
Find the value of x and y
Change this decimal to a fraction
When injected, benzedrine, dexedrine, and methamphetamine increase the release of serotonin, norepinephrine, and ______________ in the brain?