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
What happens if the both source and destination are named the same? Ans) The import operation present in MS Access does not overwrite or change any of the existing tables or obj

Write a program that input (from the user) the number of hours worked and hours pay rate for employees and output their total pay. The program should process an arbitrary number of

FACSIMILE : This is often known as 'fax' and it represents the interface between reprographic and computer technology. By using fax, the contents of a sheet of paper (text or illu

a. What are the benefits of hardwired and micro programmed control? b. Sketch neat diagram of single bus organization of CPU showing ALU, all types of registers and the data pat

Q. For function F(x,y,z) = ∑m (1,2,3,5,6) using TRUTH TABLE only 1. Find POS expression 2. Implement this simplified expression using two level OR-to-AND gate network 3. I

Q. Describe about Address Space and Memory Space? An address used by a programmer will be termed as a virtual address and set of such addresses the address space. An address in

The main function of a browser is to? The important function is to interpret HTML of a browser.

Linked list means node which is linked each other with  a line. It means that every node is connected with another one. Every node of the list hold the reference of the next node.

Q. Explain about Memory Buffer Register? Memory Buffer Register (MBR): It's a register that comprises the data to be written in memory (write operation) or it obtains the data

Q. Show the Code Conversion with example? The conversion of data from one form to another is required. Consequently we will discuss an illustration for converting a hexadecimal