Use recursion Your program will check to see if braces are balance...

Question

Use recursion
Your program will check to see if braces are balanced.
For example {} is balanced { is not.
Your program will accept a string as such {}{{}{}{ and returns true or false if the braces are balanced
Ask the user to enter the brace combos.
Print balanced or unbalanced.

Class name RemoveVowels
Write a recursive method:
public static String removeVowels(String str)
that removes all the vowels from a sentence.
For example,("This is a sentence") should return "Ths s sntnc"

Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

/* Use recursion

Your program will check to see if braces are balanced. For example {} is balanced { is not.
Your program will accept a string as such {}{{}{}{ and returns true or false if the braces are balanced
Print balanced or unbalanced. */

import java.util.Scanner;

public class Braces {

/* This function is checking if a combination of braces is entered.
* If the user enters letters, numbers or some other symbols, he will be asked to enter the string again */
public static boolean isBrace(String s) {
int countLetter = 0;
char[] ch = s.toCharArray();
for(int i = 0; i < s.length(); i++) {
if(ch[i] == '{' || ch[i] == '}')
countLetter++;
}
if(countLetter == s.length())
return true;
else
return false;
}

/* This function is checking are braces balanced. We are using recursion.*/

public static boolean isBalanced(String str)
{
if (str.charAt(0) == '{') {
return str.charAt(str.length() - 1) == '}'
&& isBalanced(str.substring(1, str.length()));
}
else
return true;
}...

By purchasing this solution you'll be able to access the following files:
SolutionBraces.java and SolutionVowels.java.

\$13.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.