Sunday, March 13, 2022

Addition, and Difference of Two Numbers in Scala

 Machine Problem

Write a program that will ask the user to give two numbers, and then the program will compute, and display the sum and difference of the two numbers on the screen.

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 in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg

Thank you very much for your support.





Program Listing

/* addition_difference.scala

   Prof. Jake Rodriguez Pomperada, MAED-IT, MIT

   www.jakerpomperada.blogspot.com and www.jakerpomperada.com

   jakerpomperada@gmail.com

   October 31, 2021    Sunday  3:18 PM

   Bacolod City, Negros Occidental

 */


import java.util.Scanner;


object addition_difference {

def main(args: Array[String]) : Unit = {

    var scanner = new Scanner(System.in);

        print("\n\n");

    print("\tAddition, and Difference  of Two Numbers in Scala");

        print("\n\n");   

print("\tEnter the first number : ");

    var a = scanner.nextInt();

print("\n");

print("\tEnter the second number : ");

var b = scanner.nextInt();


        var addition = (a+b);

        var difference = (a-b);

print("\n");

println("\tThe sum of " + a + " and " + b + " is " + addition +".");

        print("\n");

        println("\tThe difference between " + a + " and " + b + " is " + difference +".");

        print("\n");

        print("\tEnd of Program");

        print("\n\n");

}

}

No comments:

Post a Comment