Scala program to find the smallest number using scala.math.min() function
belongs to collection: Scala scala.math Package Programs
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
belongs to collection: Scala scala.math Package Programs
total answers (1)
Program/Source Code:
Here, we will read two double numbers from the user and find the smallest number between two numbers using scala.math.min() function and print the result on the console screen.
Output:
Explanation:
In the above program, we used an object-oriented approach to create the program. Here, we created an object Sample. We defined main() function. The main() function is the entry point for the program.
In the main() function, we created three variables num1, num2, minNum that are initialized with 0. Then we read both numbers from the user and then we find the smallest number using scala.math.min() function and printed the result on the console screen.
Here, scala.math is a package that contains the definition of min() function.
need an explanation for this answer? contact us directly to get an explanation for this answer