Assignment
University
California State UniversityCourse
COMP 182 | Data Structures and Program Design and LabPages
2
Academic year
2023
KauK
Views
28
import java . util . Scanner ; public class Lab6 { public static void main ( String [] args ) { Scanner scnr = new Scanner ( System . in ); int [] userValues = new int [ 20 ]; // List of integers from input /* Type your code here. */ System . out . print ( "Enter an integer which indicates how many integers you will enter: " ); int size = scnr . nextInt (); System . out . print ( "Enter your integers separated with space: " ); for ( int i = 0 ; i < size ; i ++) { userValues [ i ] = scnr . nextInt (); } //Print result System . out . println ( checkPalindrome ( userValues , size ) ? "yes" : "no" ); } public static boolean checkPalindrome ( int [] arr , int size ) { for ( int i = 0 , j = size - 1 ; i < size / 2 ; i ++, j --) { if ( arr [ i ] != arr [ j ]) return false ; } return true ; } }
Java Program to Check Palindrome: Integer Array Analysis
Please or to post comments