Friday, August 18, 2017

Product of Two Number in Scala

A very simple program that will ask the user to give two numbers and then our program will find the product of the two numbers given by our user using Scala as our programming language. The code is some what similar in Java using Java Scanner to get inputs from our user. I hope you will learn something new using Scala. Thank you.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.






Sample Program Output


Program Listing


Product.scala



import java.util.Scanner;

object Product {
def main(args: Array[String]) {
var scanner = new Scanner(System.in);
println("\n\n");
print("Product of Two Numbers in Scala");
println("\n\n");
print("Enter the first number : ");
var a = scanner.nextInt();
print("Enter the second number : ");
var b = scanner.nextInt();
println("\n\n");
println("The product of " + a + " and " + b + " is " +(a*b) +".");
println("\n\n");
println("END OF PROGRAM");
}





No comments:

Post a Comment