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