1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
prisoha [69]
3 years ago
10

Java !!!

Computers and Technology
1 answer:
coldgirl [10]3 years ago
7 0

Answer:

Explanation:

import java.util.*;

public class BalancedBrackets {

// function to check if brackets are balanced

static boolean isBalanced(String expr)

{

Stack<Character> stack = new Stack<Character>();

for (int i = 0; i < expr.length(); i++)

{

char x = expr.charAt(i);

if (x == '(' || x == '[' || x == '{')

{

// Push the element in the stack

stack.push(x);

continue;

}

if (stack.isEmpty())

return false;

char check;

switch (x) {

case ')':

check = stack.pop();

if (check == '{' || check == '[')

return false;

break;

case '}':

check = stack.pop();

if (check == '(' || check == '[')

return false;

break;

case ']':

check = stack.pop();

if (check == '(' || check == '{')

return false;

break;

}

}

// Check Empty Stack

return (stack.isEmpty());

}

public static void main(String[] args)

{

Scanner scan = new Scanner(System.in);

System.out.println("\nEnter the expression to check is balanced or not !");

String expr = scan.nextLine();

boolean output;

output = isBalanced(expr);

System.out.println(output);

if (output)

System.out.println("Balanced ");

else

System.out.println("Not Balanced ");

scan.close();

}

}

You might be interested in
Which of the following color palettes for the BackColor and ForeColor properties contains colors that are guaranteed to be displ
Norma-Jean [14]

Answer: 1)System Palette

Explanation: System palette is kind of palette found in the system which contain the color values that is used by the display.This palette is also  drawing of the devices and applications.But the application don't get the direct access to the system palette rather logical palette permits it.

They work on the basis of the properties carried from the Back color and Fore color.Other palettes mention in the option is incorrect because these palettes don't work for the operating system's display .Thus the correct option is option(1).

8 0
3 years ago
How many owners does a sole proprietorship have?
never [62]
The sole proprietorship it is the simplist business form under which one can operate a business. the answer is one.
8 0
3 years ago
What is hardware?
Dennis_Churaev [7]
The physical devices that make up a computer system
7 0
3 years ago
Read 2 more answers
What special problems can occur with wireless networks
Andreyy89
Distance from the router, as well as floors, walls, and large metal objects between a device and the router can interfere with wireless connectivity. Piggybacking, if you fail to secure your wireless network, anyone with a wireless-enabled computer in range of your access point can use your connection. Network congestion, Routers or other network equipment are overloaded with too much traffic. Speed Mismatch. This occurs when multiple users try to make use of the same server. I could go on and on.

Hope this helps!
Please give Brainliest!
3 0
2 years ago
What is shortcuts to launch spelling in ​
hichkok12 [17]

Answer:

Just hit Alt + F7 on your keyboard and it will start with the first misspelled word. If the first highlighted word at the top of the list is correct, just hit Enter. Or you can arrow to the correct one, ignore it, or Add to Dictionary.

5 0
3 years ago
Other questions:
  • What is the best use of a line chart? to show parts of a whole while emphasizing specific data to compare and contrast discrete
    9·2 answers
  • Which of the following defines a network
    7·1 answer
  • Help me decide this hurry
    12·1 answer
  • Tell me the most scariest website you know and i'll give you brainlest
    5·1 answer
  • Write the correct statements for the above logic and syntax errors in program below.
    12·1 answer
  • It is a study that aims to gather data to get the particular view,belief, or opion of a group of respondents about a specific is
    9·1 answer
  • If I am working in a document and wish to follow a hyperlink, what should I do?
    7·1 answer
  • Which of the following techniques is a direct benefit of using Design Patterns? Please choose all that apply Design patterns hel
    12·1 answer
  • How is distributed ledger technology (DLT) used in a blockchain?
    8·1 answer
  • The concepts of ________________, _________________, and _________________ for covert acts are pivotal to understanding state-on
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!