Tuesday, July 13, 2021

4. Write a program to print the product of the numbers 8.2 and 6.

 public class Main {

      public static void main(String[] args) {

          float product = 8.2f * 6.0f;

          System.out.println("The product of 8.2 and 6 is : " + product);

     }

}


NOTE:

  • Didn't need Scanner because the input from the user was already given.
  • Used float because of decimal number in the input.
  • Necessary to use f in last of the number in float.
  • In System.out.println("The product of 8.2 and 6 is : " + product); used + product to                      print value of the product.

No comments:

Post a Comment