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
In a pure combinational circuit is it necessary to mention all the inputs in sensitivity disk? if yes, why? Yes in a pure combinational circuit is it essential to mention all

Enumerate in detail about Image Scanners Drawings, graphs, colour and black-and-white photos, or text can be stored for computer processing with an image scanner by passing an

Software Estimation The statement of scope helps the planner to established estimates using one or more method which fail into two wide categories: empirical modeling and decom

Q. Disk operating system? The operating system (OS) is the first program that should be loaded into the memory of your PC before you can use it for any application. You can st

It allows code reusability. Reusability saves time in program development. It encourages the reuse of proven and debugged high-quality software, thus decreasing problem after a sys

Q. Show the steps of execution of instructions? Fetch First Instruction into CPU: Step 1: Find/calculate the address of first instruction in memory. In this machine illust

how to find the type of cohesion in a module

advantages and disadvantages of layered architecture in computer network.

Preparation of writing the program 1.  Write an algorithm for your program closer to assembly language. For instance the algorithm for preceding program will be: get NUM1

The following are the difference among Activity and Sequence Diagrams: A sequence diagram represents the way of processes implement in a sequence. For example, the order of op