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]
4 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]4 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
Pedro holds a heavy science book over his head for 10 minutes. Petro is doing work during that time. True or False
algol [13]

Answer:

True because he is working his arms to lift and hold the weight

Explanation:

4 0
3 years ago
An insulated, vertical piston-cylinder device initially contains 10kg of water, 6kg of which is in the vapor phase. The mass of
Alexeev081 [22]

Answer:

a)120C

b)29kg

Explanation:

Hello!

To solve this exercise follow the steps below

1. we will call 1 the initial state, 2 the steam that enters and 3 the final state

2. We find the quality of the initial state, dividing the mass of steam by the total mass.

q1=\frac{6kg}{10kg} =0.6

3 Find the internal energy in the three states using thermodynamic tables

note:Through laboratory tests, thermodynamic tables were developed, these allow to know all the thermodynamic properties of a substance (entropy, enthalpy, pressure, specific volume, internal energy etc ..)  

through prior knowledge of two other properties such as pressure and temperature.  

u1=IntEnergy(Water;x=0,6(quality);P=200kPa) =1719KJ/kg

u2=IntEnergy(Water;t=350;P=5000kPa) =2808KJ/kg

u3=IntEnergy(Water;x=1;P=200kPa) =2529KJ/kg

4. use the internal energy and pressure to find the temperature in state 3, using thermodynamic tables

T3=Temperature(Water;P=200kPa;u=u3=2529KJ/kg)=120C

5. Use the first law of thermodynamics in the system, it states that the initial energy in a system must be equal to the final

m1u1+m2u2=(m1+m2)u3

where

m1=inital mass=10kg

m2=the mass of the steam that has entered.

solve for m2

(m1)(u1-u3)=(m2)(u3)-(m2)(u2)

m2=m1\frac{u1-u3}{u3-u2} =10\frac{1719-2529}{2529-2808} =29kg

7 0
3 years ago
What is this spray pattern defect most likely caused by:
DiKsa [7]

Answer:

fluid nozzle that is too large

6 0
2 years ago
A geothermal heat pump absorbs 15 KJ/s of heat from the Earth 15 m below a house. This heat pump uses a 7.45 kJ/s compressor.
Anna007 [38]

Answer:

COP of the heat pump is 3.013

OP of the cycle is  1.124

Explanation:

W = Q₂ - Q₁

Given

a)

Q₂ = Q₁ + W

     = 15 + 7.45

     = 22.45 kw

COP = Q₂ / W = 22.45 / 7.45 = 3.013

b)

Q₂ = 15 x 1.055 = 15.825 kw

therefore,

Q₁ = Q₂ - W

Q₁ = 15.825 - 7.45 = 8.375

∴ COP = Q₁ / W = 8.375 / 7.45 = 1.124

4 0
4 years ago
Read 2 more answers
The steam requirements of a manufacturing facility are being met by a boiler whose rated heat input is 5.5 x 106 Btu/h. The comb
Veronika [31]

Answer:

Explanation:uhhhhhh all?

7 0
4 years ago
Other questions:
  • Water at 15°C is to be discharged from a reservoir at a rate of 18 L/s using two horizontal cast iron pipes connected in series
    7·1 answer
  • g A plane stress element has components sigma x = 160 MPa, tau xy = 100 MPa (CW). Determine the two values pf sigma y for which
    13·1 answer
  • In designing a fixed-incline self-acting thrust pad when the width of the pad is much larger than the length, it is of interest
    10·1 answer
  • In software engineering how do you apply design for change?
    13·1 answer
  • If you are involved in a collision and your vehicle is blocking the flow of traffic, you should
    5·1 answer
  • Two kilograms of air in a piston-cylinder assembly undergoes an isothermal
    11·1 answer
  • Explain the importance of water quality in aquaculture business.
    8·2 answers
  • The van der Waals equation is a modification of the ideal gas equation. What two factors does this equation account for? A. (1)
    6·1 answer
  • What is the fastest plane in the world
    13·2 answers
  • How could increasing the budget for testing have prevented the problem experienced by the mars orbiter?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!