CodersEditor Tutorials

CodersEditor Tutorials

  • Online IDE
  • Q&A
  • C Programming
  • Java
  • GraphQL.NET
  • System Software

›Java Examples

Java

    Introduction

    • Java - Overview
    • Installation & Setup
    • Program Structure
    • Keywords & Identifiers
    • Basic Data Types
    • Access Modifiers
    • Operators
    • Loops
    • Decision Statements

    Java Examples

    • Print an Integer
    • Add Two Integers
    • Multiply Two Floating Point Numbers
    • Find Ascii Value
    • Compute Quotient & Remainder
    • Swap Two Numbers using Temporary Variable
    • Swap Two Numbers without using Temporary Variable

Java Program to Multiply Two Floating Point Numbers

In this java program, you'll learn how to multiply two floating point numbers and then display the result in the console.

How to Multiply Two Floating Point Numbers in Java?

Sourcecode

/*
    Author : CodersEditor.com
    Program : Java Program to Multiply Two Floating Point Numbers
*/
public class Main {

    public static void main(String[] args) {

        float firstNumber = 25.1f;
        float secondNumber = 222.0f;

        float result = firstNumber * secondNumber;

        System.out.println("The result is: " + result);
    }
}

Output

The result is: 5572.2

Explanation

  • In this program, the two floating-point numbers are stored in the variables firstNumber and secondNumber respectively.
  • Both the floating-point variables are multiplied using the * operator and the result is stored in the variable "result" and then displayed in the cosnole using System.out.println.
note
  • When assigning the floating point variables , we have used f in the end to specify the value is a floating value and not double.
← Add Two IntegersFind Ascii Value →
  • How to Multiply Two Floating Point Numbers in Java?
    • Sourcecode
    • Output
    • Explanation
CodersEditor Tutorials
CoderdEditor Developer Tools
CodersEditor Online EditorGit Flavoured Markup EditorFree Online JSON FormatterFind My IP Address Details
Tutorials
C ProgrammingJava
Copyright © 2021 CodersEditor.com