Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 4 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 15 Sep 2017 My Price 10.00

method named justifyJava

Write a method named justifyJava that takes three parameters: an input file name, an output file name, and a tab size. Use the provided code, JavaJustifier.java, and add your code to the body of justifyJava. public static void justifyJava( String inputFileName, String outputFileName, int tabSize ) throws FileNotFoundException { /* your code goes here */ } The method should assume that the input file contains a Java program. The method opens the input file and reads the input file line by line and prints each line to System.out and to the output file with {}-blocks properly indented. Proper indentation is as follows: ? The first line of a program must have no spaces before the first non-white space character. See Note 1 below.

? Whenever a line has a {, the next line must be indented one A????1tabA????1 more than the current line. See Note 2 below. ? Whenever a line has a }, that line must be indented one A????1tabA????1 less than the previous line. See Note 3 below.

? Between the first non-white space character and the last non-white space character, the characters in the line should not be changed.

Note 1: The class String has a method named trim that removes leading and trailing white space. So if a String named str was " abc ", str = str.trim(); would change str to "abc".

Note 2: We can add one tab to the beginning of a line as follows: Example: line = one_tab + line; A tab is a type of magic number in that the number of spaces that make up a tab is completely arbitrary, so when we add a tab to our output, the number of spaces that appears is as if by magic. This means we need a constant to represent a tab: public static final int TAB_SIZE = 4; We can use that constant in our code.

The above example assumes that a String variable one_tab has the right number of spaces in it. You

can build one_tab with a for loop: String one_tab = ""; for ( int i = 0; i < TAB_SIZE; i++ ) { one_tab += " "; } To get the indent for a line correct, remove all the spaces at the beginning an end of the string, then add the right number of tabs at the beginning of the line to get the right indent.

Note 3: Example: line = line.substring( TAB_SIZE ); The above code will remove TAB_SIZE spaces from the beginning of the String named line. Expected Output: The following examples assume that a tab is 4 spaces. When I test your code, I may use a different value. I may also use a different file as input. For example, if the file contains this text: public class Test1 { public static void main( String[] args ) { System.out.println( "This is Test 1." ); } }

The program should print: public class Test1 { public static void main( String[] args ) { System.out.println( "This is Test 1." ); } } If the file contains this text: public class Test2 { public static void main( String[] args ) { System.out.println( "This is Test 2." ); } } The program should print: public class Test2 { public static void main( String[] args ) { System.out.println( "This is Test 2." ); } }

Answers

(5)
Status NEW Posted 15 Sep 2017 12:09 PM My Price 10.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)