Write a program that prompts the user for a file name, the file contains a Java
ID: 3771503 • Letter: W
Question
Write a program that prompts the user for a file name, 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. This means, you are using K&R style blocks, as in: while (i < 0) { ... } Consider using a class constant for the number of spaces to indent (4), so that it can easily be changed later.
Explanation / Answer
Progam to read the java file.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.