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
In normal operation, a paper mill generates excess steam at 20 bar and 400◦C. It is planned to use this steam as the feed to a t
Keith_Richards [23]

Answer:

The maximum power that can be generated is 127.788 kW

Explanation:

Using the steam table

Enthalpy at 20 bar = 2799 kJ/kg

Enthalpy at 2 bar = 2707 kJ/kg

Change in enthalpy = 2799 - 2707 = 92 kJ/kg

Mass flow rate of steam = 5000 kg/hr = 5000 kJ/hr × 1 hr/3600 s = 1.389 kg/s

Maximum power generated = change in enthalpy × mass flow rate = 92 kJ/kg × 1.389 kg/s = 127.788 kJ/s = 127.788 kW

6 0
3 years ago
The steel 4140 steel contains 0.4% C, however, it shows higher yield strength and ultimate strength than that of the 1045 (0.45%
Aleonysh [2.5K]

Answer:

4140 steel contains 0.4% C  having higher yield strength and ultimate strength than the 1045 steel contains 0.45% C

Explanation:

we have given 4140 steel contains 0.4% C

we know here that 4140 steel is low steel alloy , and it have low amount of chromium , manganese etc alloying element

and these elements which are present in 4140 steel they increase yield strength and ultimate strength of steel

while in 1045 steel contains 0.45 % c is plain carbon steel

and it do not contain any alloying element

so that 4140 steel contains 0.4% C  having higher yield strength and ultimate strength than the 1045 steel contains 0.45% C

4 0
3 years ago
PLEASE HELP QUICK!!
ivolga24 [154]

R01= 14.1 Ω

R02=  0.03525Ω

<h3>Calculations and Parameters</h3>

Given:

K= E2/E1 = 120/2400

= 0.5

R1= 0.1 Ω, X1= 0.22Ω

R2= 0.035Ω, X2= 0.012Ω

The equivalence resistance as referred to both primary and secondary,

R01= R1 + R2

= R1 + R2/K2

= 0.1 + (0.035/9(0.05)^2)

= 14.1 Ω

R02= R2 + R1

=R2 + K^2.R1

= 0.035 + (0.05)^2 * 0.1

= 0.03525Ω

Read more about resistance here:

brainly.com/question/17563681

#SPJ1

5 0
2 years ago
What are the two main what are the two main concerns in the research of fluid power efficiency?
Galina-37 [17]

Answer:

The correct option is;

Materials and Components

Explanation:

The efficiency of fluid power is influenced by the components and the materials used to deliver the power of the fluid as such fluid power control are focused on

1) Advances in fluid power

2) Making use of the advantages

3) Making use of the other externally available technological advantages

4) Giving allowance for disadvantages

Areas of interest in advances in fluid power are;

a. Computer optimized flow

b. The use of new and improved materials/coatings

c. The use of components that save energy, such as intelligent supply pressure adapting systems

3 0
2 years ago
Read 2 more answers
5) Calculate the LMC wal thickness of a pipe and tubing with OD as 35 + .05 and ID as 25 + .05 A) 4.95 B) 5.05 C) 10 D) 15.025
padilas [110]

Answer:

B) 5.05

Explanation:

The wall thickness of a pipe is the difference between the diameter of outer wall and the diameter of inner wall divided by 2. It is given by:

Thickness of pipe = (Outer wall diameter - Inner wall diameter) / 2

Given that:

Inner diameter = ID = 25 ± 0.05, Outer diameter = OD = 35 ± 0.05

Maximum outer diameter = 35 + 0.05 = 35.05

Minimum inner diameter = 25 - 0.05 = 24.95

Thickness of pipe = (maximum outer wall diameter - minimum inner wall diameter) / 2 = (35.05 - 24.95) / 2 = 5.05

or

Thickness = (35 - 25) / 2 + 0.05 = 10/2 + 0.05 = 5 + 0.05 = 5.05

Therefore the LMC wall thickness is 5.05

6 0
3 years ago
Read 2 more answers
Other questions:
  • The volume at a section of a 2-lane highway is 1800 vph in each direction and the density is approximately 30 bpm. A slow moving
    10·1 answer
  • Carbon dioxide (CO2) at 1 bar, 300 K enters a compressor operating at steady state and is compressed adiabatically to an exit st
    11·1 answer
  • g A 30-m-diameter sedimentation basin has an average water depth of 3.0 m. It is treating 0.3 m3/s wastewater flow. Compute over
    8·1 answer
  • Suppose three companies, Optimax, Megachug, and Thirstoid, dominate the sports drink market. Optimax enjoys the largest market s
    9·1 answer
  • Using the data from the table, what is P(3)?!
    9·1 answer
  • Which of the following best describes the basic purpose of the internet?
    7·2 answers
  • All of the following are examples of capital intensive industries EXCEPT: *
    15·2 answers
  • As you have learned, not all motor oils are the same. What are two things that make them different?.
    11·1 answer
  • This acronym is a reminder of the most common types of hazards or injuries caused by electricity.
    14·1 answer
  • A batch of 1000 is split into 10 smaller batches of equal size 100. The processing time of each unit is 2
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!