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
You have been contacted by Jean-Luc Picard commanding officer of Star Trek: The Next Generation. The Commander needs your support to develop a software routine to simulate the Robo

Method overloading is to overload methods using similar class name by writing different parameters. This is known as Method Overloading.

Unification Algorithm - Artificial intelligence: To merge two statements, we should get a substitution which forms the two sentences similar. Remember that we write V/T to sign

What is the role of MAR and MDR? The MAR (memory address register) is used to hold the address of the location to or from which data are to be transferred and the MDR(memory d

The PHP Hypertext Pre processor is a programming language that permits web developers to make dynamic content that interacts with databases. PHP is basically used for developing we

With a C program to read the text book number, title, author and publisher into a structure and print these values. # include # include void main() { struct boo

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

Raises when accessing an unassigned memory location accessing a null pointer

Q. What is communication Displays and Matrix? Communication Displays Communication displays offer support in concluding frequency of communication whether congestion in me

Q. What is Presentation layer? Presentation layer: When two hosts are communicating with each other they might use different coding standards and character sets for represent