Question
JAVA-Write a program that checks for the following balancing symbols: /* and */ ( and ) [ and ] { and } Your program should
JAVA-Write a program that checks for the following balancing symbols:
/* and */
( and )
[ and ]
{ and }
Your program should take a Java file as input named input1.java. The output can be either "matching" or "mismatching".
The input file, input1.java is below:
/////////////////////////////
public class Input1 {
public static void main(String[] args) {
try {
Scanner fileIn = new Scanner(new File("infile.txt"));
PrintWriter fileOut = new PrintWriter("out1.txt");
String line;
while (fileIn.hasNextLine()) {
line = fileIn.nextLine();
fileOut.println(line);
System.out.println(line);
}
fileIn.close();
fileOut.close();
catch (IOException ex) { System.out.println("Exception" + ex); }
}
}
//////////////////////////////////////////////
Be sure the code compiles and please include a screenshot of the output
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started