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

is (3,-5) on the line y= -2×+1?​
Which part of the nervous system contains the cerebrum and cerebellum? A. Brain B. Spinal cord C. Peripheral nervous system (PNS) D. Brain system =========
who helped Thomas paine move to Philadelphia?
Explain popular sovernty
An antigen is a protein made by your body to respond to a specific foreign molecule. Please select the best answer from the choices provided T F
Is 60% greater than 5/9
50 Points, Chem help?Some thermodynamic properties of ethanol are listed in the table. Thermodynamic PropertiesProperty Value c (solid) 0.5 J/g °C c (liquid)
Please help me on this problem. ​
How did Vietnam become a single communist nation
Write an equation in slope-intercept form of the line that has the given slope and y-intercept. m=0, b=2