Friday, May 28, 2021

Addition of Two Numbers in Scala

 A simple program to ask the user to give two numbers and then the program will compute the sum of two numbers using Scala programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.








Program Listing


Addition.scala

import java.util.Scanner;

object Addition {
 
 def main(args: Array[String]):Unit={
 
  var scanner = new Scanner(System.in);
  
  println();
  print("Addition of Two Numbers in Scala");
  println("\n");
  
  print("Enter the first number : ");
  var a = scanner.nextInt();
 
  print("Enter the second number : ");
  var b = scanner.nextInt();
  println();

  var sum = a+b;

  println(s"$a + $b = $sum");
  println();
  println("END OF PROGRAM");
  println();
 }
}

No comments:

Post a Comment