# Kotlin Program to Multiply Two Floating Point Numbers

###### Greetings!
We have recently published 100+ articles on android tutorials with kotlin and java. If you need, you may visit Android Tutorial for beginners page. You can also check Kotlin Tutorial for beginners. Also, if you are interested in content writing, you can mail us at tutorialwing@gmail.com.

In this post, we will go through kotlin program to multiply two floating point numbers

## Multiply Two Floating Point Numbers

Let’s see how to calculate product.

We use nextFloat() method to read entered floating point number.

```import java.util.*

fun main() {

println("Enter first floating number:")

println("Enter second floating number:")

val result = a * b

println("Product of \$a and \$b = \$result")
}
```

When you run the program, output will be

```Enter first floating number:
10
Enter second floating number:
21
Product of 10.0 and 21.0 = 210.0
```
###### Explanation:

We have stored two floating point numbers entered by user in variables a and b.
Then, we defined another variable result and stored product of two variables a and b.
Finally, result is shown using println()

a = read.nextFloat() means read floating point number entered by user and store it in a.

###### What if you enter some random string that can not be converted into float? Will that program run properly?

Answer – It will throw exception – InputMismatchException.

Let’s take an example, run above program again and enter 12gr when asked to enter first floating point number. Output will be –

```Enter first floating number:
12gr