Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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();
      }
}

 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9528370

Have any Question?


Related Questions in Computer Engineering

Question 1 with the explosion of users on social media

Question: 1. With the explosion of users on social media sites, businesses need to establish their presence on social media sites. Just search for "Vans" or "Starbucks" on Facebook for examples of company sites. To manag ...

Hydrogen sulfide h2s a toxic gas redolent of sewage and

Hydrogen sulfide (H2S), a toxic gas redolent of sewage and rotten eggs, is prepared from hydrochloric acid and sodium sulfide by this reaction: 2HCl(aq) + Na2S(aq) → H2S(g) + 2NaCl(aq). Determine the percent yield if 3.7 ...

An oil company determines it costs 25000 to sink a test

An oil company determines it costs $25,000 to sink a test well, an oil hit yields a net revenue of $475,000($500,000 gross-$25,000costs), and a natural gas hit yields $125,000 net revenue ($150,000 gross-$25,000 costs). ...

Question suppose that you discover that ram addresses

Question : Suppose that you discover that RAM addresses 000C0000 to 000C7FFF are reserved for a PC's video adapter in a 32-bit computer. How many bytes of memory is this?

A random sample ofnbsp87nbspeighth gradenbspstudents scores

A random sample of 87 eighth grade? students' scores on a national mathematics assessment test has a mean score of 279. This test result prompts a state school administrator to declare that the mean score for the? state' ...

How to solve this question by using r languageyou can

How to solve this question by using R Language? You can attach the Boston data set in the MASS package. library(MASS) For the Boston data set, we are interested in predicting whether a given suburb has a crime rate above ...

A static reference has the following two components in the

A static reference has the following two components in the JVM: The type of the reference; The fully qualified name of the reference, including its host class. From a security perspective for the JVM, investigate why sta ...

Develop a hypothesis that could explain why a soap created

Develop a hypothesis that could explain why a soap created from the acid CH 3 CH 2 CH 2 CH 2 COOH has poorer cleaning properties than soap made from palmitic acid. Develop a hypothesis that could explain why a soap creat ...

Question suppose the array begins with 0 followed by the

Question : Suppose the array begins with 0, followed by the remaining even integers in descending order, followed by the odd numbers in descending order. (For n = 8, the array would be [0,8,6,4,2,7,5,3,1].) How many comp ...

Question suppose that 80 community delegates discussed the

Question : Suppose that 80 community delegates discussed the transportation problems on Oahu. 30 of them favor expanding the bus system, 34 favor introduction of rail, and 44 favor building more highways. 15 favor a comb ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As