Machine Problem

Write a program to ask the users to give a string and then the program will check and determine whether the given string is a palindrome or not and display the results 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-lpOoIeJoh6gpJthPoGgThank you very much for your support.

Program Listing

/* string_palindrome.scala
   Prof. Jake Rodriguez Pomperada, MAED-IT, MIT
   www.jakerpomperada.blogspot.com and www.jakerpomperada.com
   jakerpomperada@gmail.com
   March 6, 2022   2:44 PM    Sunday
   Bacolod City, Negros Occidental
 */


import java.util.Scanner;

object string_palindrome {

  def string_palindrome_check(s : String ) : Boolean = {
      val sletters = s.toLowerCase.filter(c => c.isLetter)
      (sletters == sletters.reverse)
  }

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

    var input = new Scanner(System.in);

    var display_result = " ";

    print("\n");
    print("\tString Palindrome Using Scala");
    print("\n\n");
    print("\tGive a String :  ");
    var str_given = input.nextLine();

    if (string_palindrome_check(str_given))
        {
         display_result = "\tThe given string " + str_given + " is a Palindrome."
        } else {
            display_result = "\tThe given string " + str_given + " is Not a Palindrome."
        }
    
    print("\n");
    print(display_result);
    print("\n\n");
    print("\tEND OF PROGRAM");
    print("\n\n");
  }
}

Leave a Reply

Your email address will not be published.