Question: A pretty print program takes a program that may not be indented in any particular way and produces a copy with the same program indented

A pretty print program takes a program that may not be indented in any particular way and produces a copy with the same program indented so that bracket pairs ({ and }) line up with inner pairs indented more than outer pairs (as we have been doing throughout the book). Write a program that reads a Java program from one text file and produces a pretty print version of the program in a second text file. To make it easier, simply do this for each method, ignoring the things outside of the methods.

Step by Step Solution

3.40 Rating (172 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To write a program to pretty print a Java program you will need to do the following Read in the Java program from the input file Use a stack to track ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Data Structures and Other Objects Using Java Questions!