Print Float Variable
This program prints the value of a float variable.
Problem Statement
Write a Java program that declares a float variable and prints its value.
Source Code
| 1 | public class PrintFloat { |
| 2 | public static void main(String[] args) { |
| 3 | float price = 99.99f; |
| 4 | System.out.println("Price: " + price + " - Eduinq"); |
| 5 | } |
| 6 | } |
Program Output
Price: 99.99 - Eduinq
Explanation
A float variable price is declared using the f suffix and assigned 99.99, then printed with descriptive text, demonstrating float variable declaration and printing.