Please use Java.
Write a non-recursive method that uses a stack to check whether its string parameter is a palindrome. Write a program to test and demo your method.
Write a method that uses a stack to determine the desired Fibonacci number. Write a program to test and demo your method.
Write a method that takes a string parameter and determines whether the string contains matching grouping symbols. Grouping symbols are parenthesis ( ), curly braces { }, and brackets []. For example, the string {a(b+ac)d} and kab*cd contain matching grouping symbols. However, the strings ac)cd(e(k, xy{za(dx)k, and
{a(b+ac)d} do not contain matching grouping symbols. (Note: open and closed grouping symbols have to match both in number and in the order they occur in the string).
Write a method that uses a stack data structure to determine whether its string parameter has matching grouping symbols. Write a program to test and demo your method.
As per HomeworkLib guidelines I am answering the first full question. Please ask the remaining questions separately.
Program
package recursivepalindrome;
import java.util.Scanner;
import java.util.EmptyStackException;
import java.util.Stack;
public class RecursivePalindrome {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
Stack<Character> stack = new Stack<Character>();
System.out.print("Enter a string: ");
String input = scan.nextLine();
for (int i=0;i<input.length();i++)
{
stack.push(input.charAt(i));
}
String reverseInput = "";
while
(!stack.isEmpty()) {
reverseInput += stack.pop();
}
if (input.equals(reverseInput))
System.out.println("Palindrome.");
else
System.out.println("Not palindrome.");
}
}
Output
Enter a string: malayalam
Palindrome.
Please use Java. Write a non-recursive method that uses a stack to check whether its string...
Please use Java: Balancing Grouping Symbols Write a method that takes a string parameter and determines whether the string contains matching grouping symbols. Grouping symbols are parenthesis ( ), curly braces { }, and brackets []. For example, the string {a(b+ac)d} and kab*cd contain matching grouping symbols. However, the strings ac)cd(e(k, xy{za(dx)k, and {a(b+ac)d} do not contain matching grouping symbols. (Note: open and closed grouping symbols have to match both in number and in the order they occur in the string). Write...
Please give me that correct code for this by using C++ language. and i hope you use Visual stduio Write a function that takes a string parameter and determines whether the string contains matching grouping symbols. Grouping symbols are parenthesis ( ) , brackets [] and curly braces { }. For example, the string {a(b+ac)d[xy]g} and kab*cd contain matching grouping symbols. However, the strings ac)cd(e(k, xy{za(dx)k, and {a(b+ac}d) do not contain matching grouping symbols. (Note: open and closed grouping symbols have to match...
Write a function that takes a string parameter and determines whether the string contains matching grouping symbols. Grouping symbols are parenthesis ( ) , brackets [] and curly braces { }. For example, the string {a(b+ac)d[xy]g} and kab*cd contain matching grouping symbols. However, the strings ac)cd(e(k, xy{za(dx)k, and {a(b+ac}d) do not contain matching grouping symbols. (Note: open and closed grouping symbols have to match both in number and in the order they occur in the string). Your function must use...
Write a program that uses a recursive function to determine whether a string is a character-unit palindrome. Moreover, the options for doing case sensitive comparisons and not ignoring spaces are indicated with flags. For example "A nut for a jar of tuna" is a palindrome if spaces are ignored and not otherwise. "Step on no pets" is a palindrome whether spaces are ignored or not, but is not a palindrome if it is case sensitive. Background Palindromes are character sequences...
C++ Include a Stack class but DO NOT use STL stack, do not sumbit code that is similar to www.cplusplus.com/forum/beginner/192479/ Parenthesis Balance Problem Description Compilers require parenthesis, braces, brackets, and angled brackets to be balanced. This means that every time one is opened it must also be close AND everything between the two are also balanced. Balanced: (00) oO100) (C0O Unbalanced: (DI This is easily determined by creating a stack and reading the input. When an open parenthesis is found,...
C++ A palindrome is a string that reads the same backward as forward. For example, the words mom, dad, madam and radar are all palindromes. Write a class Pstring that is derived from the STL string class. The Pstring class adds a member functionbool isPalindrome( )that determines whether the string is a palindrome. Include a constructor that takes an STL string object as parameter and passes it to the string base class constructor. Test your class by having a main...
Stack help. I need help with my lab assignment. Complete a method for a class named Palindrome that evaluates a string phrase to determine if the phrase is a palindrome or not. A palindrome is a sequence of characters that reads the same both forward and backward. When comparing the phrase to the same phrase with the characters in reverse order, an uppercase character is considered equivalent to the same character in lowercase, and spaces and punctuation are ignored. The...
1 Overview For this assignment you are required to write a Java program that plays (n, k)-tic-tac-toe; (n, k)-tic- tac-toe is played on a board of size n x n and to win the game a player needs to put k symbols on adjacent positions of the same row, column, or diagonal. The program will play against a human opponent. You will be given code for displaying the gameboard on the screen. 2 The Algorithm for Playing (n, k)-Tic-Tac-Toe The...