Problem

Write a method called stripComments that accepts a Scanner representing an input file cont...

Write a method called stripComments that accepts a Scanner representing an input file containing a Java program as its parameter, reads that file, and then prints the file’s text with all comments removed. A comment is any text on a line from // to the end of the line, and any text between /* and */ characters. For example, consider the following text:

import java.util.*;/* My programby Suzy Student */public class Program {	public static void main(String[ ] args) {		System.out.println("Hello, world!"); // a println	}	public static /* Hello there */ void foo() {		System.out.println("Goodbye!"); // comment here	} /* */}

If the file contained this text, your program should output the following text:

import java.util.*;public class Program {	public static void main(String[ ] args) {		System.out.println("Hello, world!");	}	public static	void foo() {		System.out.println(”Goodbye!”);	}}

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 6
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT