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 limerick has four lines. True False
Rhode island passes first colonies law making slavery illegal date?!! please helpp
All dictionaries arrange the same information about words in the same way. True False Please ASAP
Igneous rocks with an andesitic composition ________.
Identify the correct sentence. a. Lou takes his studies more serious. b. Lou takes his studies seriously. c. Lou takes his studies serious. d. Lou takes his
An independent clause is missing a subject stands alone cannot stand alone is missing a verb
the gcf of two numbers is equal to the lesser of the numbers? Is this statement always, sometimes, or never true?
What are three variables that affect a living system?
Write 405,612 in expanded form
How is the conflict between Bilbo and the dwarves resolved? a. The dwarves trust Bilbo and look to him for leadership. b. The dwarves give Bilbo a share of th