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
Assume you own your own small party supply and rental business. You keep an Excel list of potential customers and clients who have rented or purchased from you in the past 2 years.

List the factors that determine the storage device performance. i.Access time ii.Cycle time iii.Transfer Rate.

Question 1 Explain the functional units of a basic computer with a neat diagram 2 What do you mean by addressing modes? List the different types of addressing modes 3 Exp


Background Information The National Aeronautics and Space Administration (NASA) is the agency within the United States Government responsible for US space exploration. Within th

System Software 1. Explain language processing? Explain its activities in detail. 2. Discuss briefly about Assembler directives. Also explain about Macro definition and call

Question: a) The following is a description of the navigation options in a mobile web site which provides public bus time slots for a city. It is an interesting service for m

Define underflow and overflow. Underflow: If the result the arithmetic operation including n-bit numbers is too small to show by n-bits, underflow is said to occur. Overflow

Firewalls While getting one firewall for the company's Intranet it should be well known that firewalls come in both hardware and software forms, and that even though all firew

Give detail explanation about Arithmetic Micro-operations These micro-operations perform some essential arithmetic operations on numeric data stored in the registers. These bas