Print Double Variable
This program prints the value of a double variable to the console.
Problem Statement
Write a Java program that declares a double variable and prints its value.
Source Code
| 1 | public class PrintDouble { |
| 2 | public static void main(String[] args) { |
| 3 | double pi = 3.14159; |
| 4 | System.out.println("The value of pi is: " + pi + " - Eduinq"); |
| 5 | } |
| 6 | } |
Program Output
The value of pi is: 3.14159 - Eduinq
Explanation
double pi = 3.14159; Declares a double variable named pi and assigns it the value 3.14159. System.out.println("The value of pi is: " + pi + " - Eduinq"); Prints a message along with the value of pi, followed by Eduinq branding. Closing braces } End of method and class. Conclusion: This program demonstrates how to declare and print a double variable. It shows how floating point values can be displayed with text output.