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 is a half-adder? Explain a half-adder with the help of truth-table and logic diagram. Ans. Half Adder: It is a logic circuit for the addition of two 1-bit numbers is term

Write a PERL script which takes a file named input.txt as an input and processes it. The input file has the following format: firstname lastname: pass/fail score%. A sample input f

You are required to use software of your choice (spreadsheet, database, statistical package etc) to analyze the provided SAP security audit log data ( Userdata.xls ), generate appr

Will executing  SAP R/3 across the entire PCD division give the division with a competitive benefit?  Clarify  your answer carefully.

difference between pure and impute inter preter

Example of Weight training calculations: Through having calculated all the error values associated with such each unit like hidden and output then we can now transfer this inf

Write a short notes on transition from IPv4 to IPv6

WLS8 handles JMX but it uses weblogic execution of JMX server. It does not supports generalise sun javax API which can be used with any JVM. There are some patches available which

Explain Clone process. A clone process is generated using primitive type clone by duplicating its parent process. However unlike traditional processes it might be share its con

How is Transaction Processing System affect performance of e-commerce sites? Transaction Processing System influences performance of e-commerce sites: Transaction-Processing