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
There are various approaches to the classification of Computer Networks. One such classification is based on distance approach. Networks can be classified into LAN, WAN and MAN net

Software engineering is:- The application of a disciplined engineering move towards to the development of software systems. A body of information and knowledge in software d

An array is referencing using a base array value as well as an index. To simplify addressing in arrays 8086 has provided two index registers for mathematical computations viz. BP a

1. How does this new generation of ERP products differ from traditional solutions? 2. What are the major external forces driving competition in the ERP industry? Cloud comput


How can you manipulate the presentation and attributes of interactive lists? ---Scrolling by Interactive Lists. ---Setting the Cursor from within the Program. ---Changing

Q. Describe the basic aspects of ENIAC? The main aspects of ENIAC can be summarized as: ENIAC was a general purpose-computing machine in that vacuum tube technology was

Solution of multi-layer ann with sigmoid units: Assume here that we input the values 10, 30, 20 with the three input units and from top to bottom. So after then the weighted s

What are the uses of Router? Router: A router is used to transfer or route data among two or more similar networks. This determines the next network point to that a data

What are advantages and disadvantages of TTL gates design with Wired-AND connection ? Ans. Advantages and disadvantages In this IC added logic is performed with