Write a method called doubleSpace that accepts a Scanner for an input file and a PrintStream for an output file as its parameters, writing into the output file a double-spaced version of the text in the input file.

Answer :

Answer:

The method definition to this question as follows:

Method definition:

void doubleSpace(Scanner input, PrintStream output) //defining method doubleSpace that reads the input file

{

   while (input.hasNextLine()) //loop for input values

{

output.println(input.nextLine()); //using print method  

output.println();  //using print method

   }

}

Explanation:

In the above method definition, a method "double-space" is declared, which accepts two parameters, "input and output", in which input is used to take input from the file, with the help of Scanner class, and the output is used to print its value.

  • Inside the method, a while loop is declared, that take input from the file, and uses the print method.
  • In this method, the output uses the print method to print its value.

Other Questions