Answer:
See the code and explanation below
Explanation:
Is neccesary that accepts a Scan representing a file as a parameter and writes that file's text on the language, and we need to reduce the multiple spaces to single spaces between words that appear using just one line. Each word is to appear on the same line in output as it appears in the file. We need to consider that the lines can be blank.
The code on Jave is this one:
public void DavidSpaces(Scan sc) {
while(sc.hasNextLine()) {
String line = sc.nextLine();
Scanner linesc = new Scan(line);
while(linesc.hasNext())
System.out.print(linesc.next() + " ");
System.out.println();
}
}
The algorithm scheme is given on the picture attached.