File history.d1 contains a brief history of computing, Computer Engineering

File History.d1 contains a brief history of computing. There are no indentations in this file. Write a program to read this file, inserting five blank spaces at the beginning of each paragraph. You can recognize a paragraph because a blank line appears before the first line of each paragraph. Write the changed file on History.d2. In the program documentation, described the loop(s) used as count - controlled or event -controlled.

  • Use the following loop as a model:

// Application IOLoop counts the number of blanks per line
// and the number of lines in a file
import java.io.*;
import java.util.Scanner;
public class IOLoop
{
      public static Scanner inFile;
      public static PrintWriter outFile;
 public static void main(String[] args) throws IOException
      {
        int lineCount = 0;
        int blankCount;
        int index;
        String inputString;
        inFile = new Scanner(new FileReader("history.dat"));
        outFile = new PrintWriter(new FileWriter("data.out"));
    while (inFile.hasNextLine())
        {
     inputString = inFile.nextLine();
          lineCount++;
          blankCount = 0;
          index = inputString.indexOf(' ');
          while (index != -1)
          {
            blankCount++;
            if (inputString.length() != 1)
            {
              inputString = inputString.substring(index+1,
                inputString.length());
              index = inputString.indexOf(' ');
            }
            else index = -1;
          }
          outFile.println("Line " + lineCount + " contains "
            + blankCount + " blanks.");
        }
        outFile.close();
        inFile.close();
      }
}

 

Posted Date: 3/13/2013 8:52:22 AM | Location : United States







Related Discussions:- File history.d1 contains a brief history of computing, Assignment Help, Ask Question on File history.d1 contains a brief history of computing, Get Answer, Expert's Help, File history.d1 contains a brief history of computing Discussions

Write discussion on File history.d1 contains a brief history of computing
Your posts are moderated
Related Questions
Which loader is executed when a system is first turned on or restarted? Ans. Bootstrap loader executed while a system is first turned on or restarted.

Traffic Capacity is given by? Traffic Capacity = Switching capacity × Theoretical maximum load.

Explain Pure and impure interpreters In a pure interpreter, the source program is retained into the source form all throughout its interpretation. These arrangements incur subs

What is C++ reference and JAVA final? Association ends must be bound at initialization and cannot be altered. C++ references can fully enforce these semantics, and the JAVA fin

Q. Illustrate Memory Read operation? Memory unit receives the address from a register known as the memory address register designated by MAR. Data is transferred to another re

What is "at exit-command:? The flow logic Keyword at EXIT-COMMAND is a special addition to the MODULE statement in the Flow Logic .AT EXIT-COMMAND lets you call a module befor


Q. Define COM Programs? A COM (Command) program is binary image of a machine language program. It is loaded in memory at the lowest available segment address. Program code star

When can a user program execution be interrupted? It won't be desirable to interrupt a program when an instruction is being executed and is in a state such as instruction decod

Explain the Architectural description languages Architectural description languages (ACLs) have been developed for the architectural description in analysis and design process