CAN SOMEONE PLEASE ANSWER THIS NOW ITS DUE IN ABOUT 1HOUR/HALF. THANKS Write a p
ID: 3911466 • Letter: C
Question
CAN SOMEONE PLEASE ANSWER THIS NOW ITS DUE IN ABOUT 1HOUR/HALF. THANKS
Write a program that reads in a Java source file. Your program uses recursion to correct any indention in the program to follow proper indentation style. This means that lines following a { should be indented and lines following } should be de-indented. Your program should probably strip off any leading white space before starting the indentation to make sure that everything is in a sane state. Assume that { and } will not appear on the same line though if you are able to deal with that case, all the better. Any other assumptions that are being made should be a) double-checked on the discussion forum and b) stated at the top of your program. Consider the following proof-of-concept example:
Original: main(){ if(x>5){ System.out.println("Hello"); x=10; } else{ if(x==3){ System.out.println("Three"); } } }
Formatted output: main(){ if(x>5){ System.out.println("Hello"); x=10; } else{ if(x==3){ System.out.println("Three"); } } }
Explanation / Answer
Here is the correct way of using indentation(3- spaces) in the given program code:
Main()
{
if(x>5)
{
System.out.println("Hello");
x=10;
}
else
{
if(x==3)
{
System.out.println("Three");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.