Friday, August 25, 2017

Finding the Biggest Value Using Scala

Hi Guys in this article I would like to share with you how to use one dimensional array in Scala and how we can able to determine which of the values in our array is the highest in terms of numerical value. The code is very short and easy to understand. I am using IntelliJ IDEA community edition 2017.2 edition as my text editor in writing this code. I hope you will find my work useful. Thank you very much for all the support in my website.

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


Biggest.scala


object Biggest {

  def main(args: Array[String]) {

    var listValues = Array(100,45,1240,12,50,531,62,376);

    print("\n\n");
    print("Finding the Biggest Value Using Scala");
    print("\n\n");
    print("Written By: Mr. Jake R. Pomperada, MAED-IT");
    print("\n\n");

    for ( a <- listValues ) {
      print(" " + a + " ");
    }

    var biggest = listValues(0);

    for ( b <- 1 to (listValues.length - 1) ) {
      if (listValues(b) > biggest)
        biggest = listValues(b);
    }
    print("\n\n");
    println("The Biggest Number is " + biggest + ".");
    print("\n\n");
    print("\t END OF PROGRAM");
    print("\n\n");
  }
}

No comments:

Post a Comment