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
Deductive Inferences - Artificial intelligence: We have described how knowledge can be represented in first-order logic, and how in logic rule-based expert systems expressed ca

Can you tell me some of system tasks and their purpose? $display, $displayb, $displayh, $displayo, $write, $writeb, $writeh, $writeo. The most useful of these is $display. T

import java.util.Scanner;   class AddNumbers {    public static void main(String args[])    {       int x, y, z;       System.out.println("Enter two integers to calculate their sum

Create your own Subprogram that uses at least 1input parameter and a return parameter. You decide the theme. You should give the pseudocode and an example Subroutine call. Be sure

What is difference between RAM and FIFO? FIFO certainly does not have address lines. It is stands for first in and first out. It is an algorithm based method. It is used to s

How to maintain lists? To return from a high list level to the next-lower level (SY-LSIND), the user chooses back on a secondary list.  The system then gives the currently dis

What do you understand by WWW WWW: The World Wide is an architectural framework for accessing linked documents increase out over thousands of machines all over the world. It

what is bitmap and pixmap

Before we take a detailed look about the Motorola 68HC11 series of micro controllers it is useful to define what is meant by a micro controller. As the name suggests a micro contro

Artificial Intelligence Robotics covers all the material required to understand the principles behind the AI approach to robotics and to program an artificially intelligent robot f