SlideShare ist ein Scribd-Unternehmen logo
1 von 1
Downloaden Sie, um offline zu lesen
import java.util.Stack; import java.util.Scanner; class PalindromeDemo { public static void
main(String[] args) { System.out.print("Enter any string:"); Scanner in=new
Scanner(System.in); String inputString = in.nextLine(); Stack stack = new Stack();
for (int i = 0; i < inputString.length(); i++) { stack.push(inputString.charAt(i)); }
String reverseString = ""; while (!stack.isEmpty()) { reverseString =
reverseString+stack.pop(); } if (inputString.equals(reverseString))
System.out.println("The input String is a palindrome."); else
System.out.println("The input String is not a palindrome."); } }
Solution
import java.util.Stack; import java.util.Scanner; class PalindromeDemo { public static void
main(String[] args) { System.out.print("Enter any string:"); Scanner in=new
Scanner(System.in); String inputString = in.nextLine(); Stack stack = new Stack();
for (int i = 0; i < inputString.length(); i++) { stack.push(inputString.charAt(i)); }
String reverseString = ""; while (!stack.isEmpty()) { reverseString =
reverseString+stack.pop(); } if (inputString.equals(reverseString))
System.out.println("The input String is a palindrome."); else
System.out.println("The input String is not a palindrome."); } }

Weitere ähnliche Inhalte

Ähnlich wie import java.util.Stack; import java.util.Scanner; class PalindromeDe.pdf

CODEimport java.util.; public class test { public static voi.pdf
CODEimport java.util.; public class test { public static voi.pdfCODEimport java.util.; public class test { public static voi.pdf
CODEimport java.util.; public class test { public static voi.pdfanurag1231
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfoptokunal1
 
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...Sunil Kumar Gunasekaran
 
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfimport java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfshettysachin2005
 
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdfPrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdfAnkitchhabra28
 
Prompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfPrompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfFootageetoffe16
 
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdfSumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdfankkitextailes
 
import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfmanojmozy
 

Ähnlich wie import java.util.Stack; import java.util.Scanner; class PalindromeDe.pdf (8)

CODEimport java.util.; public class test { public static voi.pdf
CODEimport java.util.; public class test { public static voi.pdfCODEimport java.util.; public class test { public static voi.pdf
CODEimport java.util.; public class test { public static voi.pdf
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdf
 
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
 
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfimport java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
 
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdfPrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
 
Prompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfPrompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdf
 
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdfSumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
 
import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdf
 

Mehr von annethafashion

8. D) trapping records kept on non-scientists can provide useful rec.pdf
8. D) trapping records kept on non-scientists can provide useful rec.pdf8. D) trapping records kept on non-scientists can provide useful rec.pdf
8. D) trapping records kept on non-scientists can provide useful rec.pdfannethafashion
 
1. X-linked ichthyosis.............X-linked recessive diseaseSol.pdf
1. X-linked ichthyosis.............X-linked recessive diseaseSol.pdf1. X-linked ichthyosis.............X-linked recessive diseaseSol.pdf
1. X-linked ichthyosis.............X-linked recessive diseaseSol.pdfannethafashion
 
1f=1s+1ptaking 1s to the left1f-1s=1ptaking LCD of f and .pdf
1f=1s+1ptaking 1s to the left1f-1s=1ptaking LCD of f and .pdf1f=1s+1ptaking 1s to the left1f-1s=1ptaking LCD of f and .pdf
1f=1s+1ptaking 1s to the left1f-1s=1ptaking LCD of f and .pdfannethafashion
 
in the beginning he had x denarii. After leaving Lucca he had 2x .pdf
 in the beginning he had x denarii. After leaving Lucca he had 2x .pdf in the beginning he had x denarii. After leaving Lucca he had 2x .pdf
in the beginning he had x denarii. After leaving Lucca he had 2x .pdfannethafashion
 
operating system Ubunut,Linux,Mac filename messageService.cpp.pdf
 operating system Ubunut,Linux,Mac filename messageService.cpp.pdf operating system Ubunut,Linux,Mac filename messageService.cpp.pdf
operating system Ubunut,Linux,Mac filename messageService.cpp.pdfannethafashion
 
x^2 = H+ ^2 = 0.61.310^-5 hence H+ = 0.00134 M.pdf
                     x^2 = H+ ^2 = 0.61.310^-5  hence H+ = 0.00134 M.pdf                     x^2 = H+ ^2 = 0.61.310^-5  hence H+ = 0.00134 M.pdf
x^2 = H+ ^2 = 0.61.310^-5 hence H+ = 0.00134 M.pdfannethafashion
 
sp3 Solution sp3 .pdf
                     sp3  Solution                     sp3  .pdf                     sp3  Solution                     sp3  .pdf
sp3 Solution sp3 .pdfannethafashion
 
M=Molalityd=1.59 M .pdf
                     M=Molalityd=1.59 M                              .pdf                     M=Molalityd=1.59 M                              .pdf
M=Molalityd=1.59 M .pdfannethafashion
 
Ibuprofen is a carboxylic acid. It will react wit.pdf
                     Ibuprofen is a carboxylic acid. It will react wit.pdf                     Ibuprofen is a carboxylic acid. It will react wit.pdf
Ibuprofen is a carboxylic acid. It will react wit.pdfannethafashion
 
halogens are nonpolar molecules. water is polar, .pdf
                     halogens are nonpolar molecules. water is polar, .pdf                     halogens are nonpolar molecules. water is polar, .pdf
halogens are nonpolar molecules. water is polar, .pdfannethafashion
 
b. because the physician advertised his services .pdf
                     b. because the physician advertised his services .pdf                     b. because the physician advertised his services .pdf
b. because the physician advertised his services .pdfannethafashion
 
Yes linear model would be appropriateReason a ) linearityof.pdf
Yes linear model would be appropriateReason a ) linearityof.pdfYes linear model would be appropriateReason a ) linearityof.pdf
Yes linear model would be appropriateReason a ) linearityof.pdfannethafashion
 
Use of assembly language[edit]Historical perspective[edit]Assemb.pdf
Use of assembly language[edit]Historical perspective[edit]Assemb.pdfUse of assembly language[edit]Historical perspective[edit]Assemb.pdf
Use of assembly language[edit]Historical perspective[edit]Assemb.pdfannethafashion
 
The five components of internal control are1)Control enviornment .pdf
The five components of internal control are1)Control enviornment .pdfThe five components of internal control are1)Control enviornment .pdf
The five components of internal control are1)Control enviornment .pdfannethafashion
 
a. HF is the most polar molecule Reason because.pdf
                     a. HF is the most polar molecule  Reason because.pdf                     a. HF is the most polar molecule  Reason because.pdf
a. HF is the most polar molecule Reason because.pdfannethafashion
 
In accounting and economics, fair value is a rational and unbiased e.pdf
In accounting and economics, fair value is a rational and unbiased e.pdfIn accounting and economics, fair value is a rational and unbiased e.pdf
In accounting and economics, fair value is a rational and unbiased e.pdfannethafashion
 
it is given cost of wire consider1 centdistance(D)2D3for th.pdf
it is given cost of wire consider1 centdistance(D)2D3for th.pdfit is given cost of wire consider1 centdistance(D)2D3for th.pdf
it is given cost of wire consider1 centdistance(D)2D3for th.pdfannethafashion
 
I will choose the -1.)A widower in her thirties with three small ch.pdf
I will choose the -1.)A widower in her thirties with three small ch.pdfI will choose the -1.)A widower in her thirties with three small ch.pdf
I will choose the -1.)A widower in her thirties with three small ch.pdfannethafashion
 
Facts of the caseCity Transportation Company (CTC) agrees to pick .pdf
Facts of the caseCity Transportation Company (CTC) agrees to pick .pdfFacts of the caseCity Transportation Company (CTC) agrees to pick .pdf
Facts of the caseCity Transportation Company (CTC) agrees to pick .pdfannethafashion
 
First Informers in the Disaster Zone  It hold a summary of the insig.pdf
First Informers in the Disaster Zone  It hold a summary of the insig.pdfFirst Informers in the Disaster Zone  It hold a summary of the insig.pdf
First Informers in the Disaster Zone  It hold a summary of the insig.pdfannethafashion
 

Mehr von annethafashion (20)

8. D) trapping records kept on non-scientists can provide useful rec.pdf
8. D) trapping records kept on non-scientists can provide useful rec.pdf8. D) trapping records kept on non-scientists can provide useful rec.pdf
8. D) trapping records kept on non-scientists can provide useful rec.pdf
 
1. X-linked ichthyosis.............X-linked recessive diseaseSol.pdf
1. X-linked ichthyosis.............X-linked recessive diseaseSol.pdf1. X-linked ichthyosis.............X-linked recessive diseaseSol.pdf
1. X-linked ichthyosis.............X-linked recessive diseaseSol.pdf
 
1f=1s+1ptaking 1s to the left1f-1s=1ptaking LCD of f and .pdf
1f=1s+1ptaking 1s to the left1f-1s=1ptaking LCD of f and .pdf1f=1s+1ptaking 1s to the left1f-1s=1ptaking LCD of f and .pdf
1f=1s+1ptaking 1s to the left1f-1s=1ptaking LCD of f and .pdf
 
in the beginning he had x denarii. After leaving Lucca he had 2x .pdf
 in the beginning he had x denarii. After leaving Lucca he had 2x .pdf in the beginning he had x denarii. After leaving Lucca he had 2x .pdf
in the beginning he had x denarii. After leaving Lucca he had 2x .pdf
 
operating system Ubunut,Linux,Mac filename messageService.cpp.pdf
 operating system Ubunut,Linux,Mac filename messageService.cpp.pdf operating system Ubunut,Linux,Mac filename messageService.cpp.pdf
operating system Ubunut,Linux,Mac filename messageService.cpp.pdf
 
x^2 = H+ ^2 = 0.61.310^-5 hence H+ = 0.00134 M.pdf
                     x^2 = H+ ^2 = 0.61.310^-5  hence H+ = 0.00134 M.pdf                     x^2 = H+ ^2 = 0.61.310^-5  hence H+ = 0.00134 M.pdf
x^2 = H+ ^2 = 0.61.310^-5 hence H+ = 0.00134 M.pdf
 
sp3 Solution sp3 .pdf
                     sp3  Solution                     sp3  .pdf                     sp3  Solution                     sp3  .pdf
sp3 Solution sp3 .pdf
 
M=Molalityd=1.59 M .pdf
                     M=Molalityd=1.59 M                              .pdf                     M=Molalityd=1.59 M                              .pdf
M=Molalityd=1.59 M .pdf
 
Ibuprofen is a carboxylic acid. It will react wit.pdf
                     Ibuprofen is a carboxylic acid. It will react wit.pdf                     Ibuprofen is a carboxylic acid. It will react wit.pdf
Ibuprofen is a carboxylic acid. It will react wit.pdf
 
halogens are nonpolar molecules. water is polar, .pdf
                     halogens are nonpolar molecules. water is polar, .pdf                     halogens are nonpolar molecules. water is polar, .pdf
halogens are nonpolar molecules. water is polar, .pdf
 
b. because the physician advertised his services .pdf
                     b. because the physician advertised his services .pdf                     b. because the physician advertised his services .pdf
b. because the physician advertised his services .pdf
 
Yes linear model would be appropriateReason a ) linearityof.pdf
Yes linear model would be appropriateReason a ) linearityof.pdfYes linear model would be appropriateReason a ) linearityof.pdf
Yes linear model would be appropriateReason a ) linearityof.pdf
 
Use of assembly language[edit]Historical perspective[edit]Assemb.pdf
Use of assembly language[edit]Historical perspective[edit]Assemb.pdfUse of assembly language[edit]Historical perspective[edit]Assemb.pdf
Use of assembly language[edit]Historical perspective[edit]Assemb.pdf
 
The five components of internal control are1)Control enviornment .pdf
The five components of internal control are1)Control enviornment .pdfThe five components of internal control are1)Control enviornment .pdf
The five components of internal control are1)Control enviornment .pdf
 
a. HF is the most polar molecule Reason because.pdf
                     a. HF is the most polar molecule  Reason because.pdf                     a. HF is the most polar molecule  Reason because.pdf
a. HF is the most polar molecule Reason because.pdf
 
In accounting and economics, fair value is a rational and unbiased e.pdf
In accounting and economics, fair value is a rational and unbiased e.pdfIn accounting and economics, fair value is a rational and unbiased e.pdf
In accounting and economics, fair value is a rational and unbiased e.pdf
 
it is given cost of wire consider1 centdistance(D)2D3for th.pdf
it is given cost of wire consider1 centdistance(D)2D3for th.pdfit is given cost of wire consider1 centdistance(D)2D3for th.pdf
it is given cost of wire consider1 centdistance(D)2D3for th.pdf
 
I will choose the -1.)A widower in her thirties with three small ch.pdf
I will choose the -1.)A widower in her thirties with three small ch.pdfI will choose the -1.)A widower in her thirties with three small ch.pdf
I will choose the -1.)A widower in her thirties with three small ch.pdf
 
Facts of the caseCity Transportation Company (CTC) agrees to pick .pdf
Facts of the caseCity Transportation Company (CTC) agrees to pick .pdfFacts of the caseCity Transportation Company (CTC) agrees to pick .pdf
Facts of the caseCity Transportation Company (CTC) agrees to pick .pdf
 
First Informers in the Disaster Zone  It hold a summary of the insig.pdf
First Informers in the Disaster Zone  It hold a summary of the insig.pdfFirst Informers in the Disaster Zone  It hold a summary of the insig.pdf
First Informers in the Disaster Zone  It hold a summary of the insig.pdf
 

Kürzlich hochgeladen

Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 

Kürzlich hochgeladen (20)

Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 

import java.util.Stack; import java.util.Scanner; class PalindromeDe.pdf

  • 1. import java.util.Stack; import java.util.Scanner; class PalindromeDemo { public static void main(String[] args) { System.out.print("Enter any string:"); Scanner in=new Scanner(System.in); String inputString = in.nextLine(); Stack stack = new Stack(); for (int i = 0; i < inputString.length(); i++) { stack.push(inputString.charAt(i)); } String reverseString = ""; while (!stack.isEmpty()) { reverseString = reverseString+stack.pop(); } if (inputString.equals(reverseString)) System.out.println("The input String is a palindrome."); else System.out.println("The input String is not a palindrome."); } } Solution import java.util.Stack; import java.util.Scanner; class PalindromeDemo { public static void main(String[] args) { System.out.print("Enter any string:"); Scanner in=new Scanner(System.in); String inputString = in.nextLine(); Stack stack = new Stack(); for (int i = 0; i < inputString.length(); i++) { stack.push(inputString.charAt(i)); } String reverseString = ""; while (!stack.isEmpty()) { reverseString = reverseString+stack.pop(); } if (inputString.equals(reverseString)) System.out.println("The input String is a palindrome."); else System.out.println("The input String is not a palindrome."); } }