Java Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | package javaexamples; import java.util.Scanner; public class JavaExamples { public static void main(String[] args) { float first = 1.554f; float second = 2.0f; float product = first * second; String output = String.format("%.2f * %.2f = %.2f",first,second,product); System.out.println(output); } } |
Output: