Question
Write a program that prompts the user for a file name, assuming the file contains a Java program. Your program should read the file and
Write a program that prompts the user for a file name, assuming the file contains a Java program. Your program should read the file and print to a file its contents properly indented. When you see a left-brace character ({) in the file, increase your indentation level by four spaces. When you see a right-brace character }(), decrease your indentation level by four spaces. You may assume that the file has only one opening or closing brace per line, that every block statement (such as if or for) uses braces rather than omitting them, and that every relevant occurrence of a { or } character in the file occurs at the end of a line. Consider using a class constant for the number of spaces to indent (4), so that it can easily be changed later.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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