Add Two Numbers in Scala
In this example, we will show you how to add two numbers in scala program language. The sample program and output has been attached in the same post.
Example Code
import java.util.Scanner; object Addition { def main(args: Array[String]) { // defining the scanner object var scanner = new Scanner(System.in); println("Enter the first number : "); // reading input from user var a = scanner.nextInt(); println("Enter the second number : "); // reading input from user var b = scanner.nextInt(); println("The Result is : "+(a+b)); } }
Output
Enter the first number :
20
Enter the second number :
30
The Result is : 50
More from my site

Hello, folks, I am a founder of idineshkrishnan.com. I love open source technologies, If you find my tutorials are useful, please consider making donations to these charities.
No responses yet