1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
e-lub [12.9K]
3 years ago
7

Write a program that asks the user for the name of a file. The program should display the number of words that the file contains

. The file to test your program on is attached to the assignment folder. It is called Lorem.txt.
Engineering
1 answer:
Flura [38]3 years ago
3 0

Answer:

import java.io.*;

import java.util.Scanner;

public class CountWordsInFile {

   public static void main(String[] args) throws IOException {

       Scanner keyboard = new Scanner(System.in);

       System.out.print("Enter file name: ");

       String fileName = keyboard.next();

       File file = new File(fileName);

       try {

       

           Scanner scan = new Scanner(file);

           

           int count = 0;

           

           while(scan.hasNext()) {

               scan.next();

               count += 1;

           }

           scan.close();

           System.out.println("Number of words: "+count);        

       } catch (FileNotFoundException e) {

           System.out.println("File " + file.getName() + " not present ");

           System.exit(0);

       }

   }

}

You might be interested in
What is the federal E-Rate program?
Annette [7]

Answer:

c. A program that offers discounts to libraries and schools ensuring they have affordable access to modern telecommunications and information services.

Explanation:

Federal E-Rate program refers to the Schools and Libraries Program of the Universal Service Fund managed by the Universal Service Administrative Company (USAC) and being directed by the Federal Communications Commission (FCC).

The program offers telecommunications and internet access to schools and libraries in the United States at discounts of between 20% and 90% in order to make the services affordable to them.

The discounts received by each of he beneficiary schools receive which is between the rage of 20% and 90% is determined by the degree of poverty and the urban/rural status of the population or students being served.

In the program, connectivity and maintenance services are provided by the Schools and Libraries Program, while school that applied to the program has to provide other items like software, hardware (e.g. computers), and among other items that will make then to use the connectivity provided.

I wish you the best.

8 0
3 years ago
Just need someone to talk to pls dont just use me for points
Allushta [10]

Answer:

well what do you wanna talk about friend?

Explanation:

7 0
3 years ago
Why is the reflection step in the engineering process the most important step?
Monica [59]
Reflection helps designers to learn from their experiences, to integrate and co-ordinate different aspects of a design situation, to judge the progress of the design process, to evaluate interactions with the design context, and to plan suitable future design activities.
6 0
2 years ago
Consider the following statement concerned with the collection of data, and determine the best selection of terms to complete th
snow_lady [41]

Answer:

a. population, units, sample

Explanation:

In a survey or in a research, population is defined as the total number of people or total number of items in the group that we want to study in a research. It is the entire pool from where a sample is drawn.

An unit is defined as the individual members for which the information or data is collected.

A sample is defined is defined as the group or part of the selection from where the information or data is to be obtained.

8 0
3 years ago
5. Consider the LTI system defined by the differential equation (a) Draw the pole-zero plot for the system. Is the system stable
stealth61 [152]

Answer:

Detailed solution is attached in the images below showing step wise solution and answer for each part individually.

8 0
3 years ago
Other questions:
  • Use the convolutional integral to find the response of an LTI system with impulse response ℎ(????) and input x(????). Sketch the
    8·1 answer
  • Consider a cylindrical specimen of some hypothetical metal alloy that has a diameter of 11.0 mm. A tensile force of 1550 N produ
    7·1 answer
  • Steam flows at steady state through a converging, insulated nozzle, 25 cm long and with an inlet diameter of 5 cm. At the nozzle
    11·1 answer
  • The densities of several materials are given in SI units. Convert these to densities in U.S. customary units (slug/ft3), and als
    12·1 answer
  • Electrical pressure or “force”<br><br> A) current<br> B) resistance <br> C) voltage
    6·1 answer
  • 5) Initially, the pressure and temperature of steam inside a solid capsule is at 100-pound force per square inch absolute (psia)
    6·1 answer
  • The removed soil at an excavation site is also called spoil?​
    14·1 answer
  • Does an electronic clock use electrical energy?​
    10·2 answers
  • Write down about the water source selection criteria​
    9·1 answer
  • What do you mean by overflow and underflow error in array?.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!