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 firstFloat = reader.nextFloat(); System.out.print("Enter Second Number: "); int secondInt = reader.nextInt(); float product = firstFloat * (float) secondInt; String output = String.format("%.2f * %d = %.2f",firstFloat,secondInt,product); System.out.println(output); } } |
Output: