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
g Consider a thin opaque, horizontal plate with an electrical heater on its backside. The front end is exposed to ambient air th
xxTIMURxx [149]

Answer:

The electrical power is 96.5 W/m^2

Explanation:

The energy balance is:

Ein-Eout=0

qe+\alpha sGs+\alpha skyGsky-EEb(Ts)-qc=0

if:

Gsky=oTsky^4

Eb=oTs^4

qc=h(Ts-Tα)

\alpha s=\frac{\int\limits^\alpha _0 {\alpha l Gl} \, dl }{\int\limits^\alpha _0 {Gl} \, dl }

\alpha s=\frac{\int\limits^\alpha _0 {\alpha lEl(l,5800 } \, dl }{\int\limits^\alpha _0 {El(l,5800)} \, dl }

if Gl≈El(l,5800)

\alpha s=(1-0.2)F(0-2)+(1-0.7)(1-F(0-2))

lt= 2*5800=11600 um-K, at this value, F=0.941

\alpha s=(0.8*0.941)+0.3(1-0.941)=0.77

The hemispherical emissivity is equal to:

E=(1-0.2)F(0-2)+(1-0.7)(1-F(0-2))

lt=2*333=666 K, at this value, F=0

E=0+(1-0.7)(1)=0.3

The hemispherical absorptivity is equal to:

qe=EoTs^{4}+h(Ts-T\alpha  )-\alpha sGs-\alpha oTsky^{4}=(0.3*5.67x10^{-8}*333^{4})+10(60-20)-(0.77-600)-(0.3*5.67x10^{-8}*233^{4})=96.5 W/m^{2}

3 0
3 years ago
A binary geothermal power plant uses geothermal water at 160°C as the heat source. The cycle operates on the simple Rankine cycl
bogdanovich [222]

A binary geothermal power operates on the simple Rankine cycle with isobutane as the working fluid. The isentropic efficiency of the turbine, the net power output, and the thermal efficiency of the cycle are to be determined

Assumptions :

1.  Steady operating conditions exist.

2.  Kinetic and potential energy changes are negligible.

Properties:  The specific heat of geothermal water ( c_{geo}[) is taken to be 4.18 kJ/kg.ºC.  

Analysis (a) We need properties of isobutane, we can obtain the properties from EES.

a. Turbine

PP_{3} = 3.25mPa = (3.25*1000) kPa\\= 3250kPa\\from the EES TABLE\\h_{3} = 761.54 kJ/kg\\s_{3} = 2.5457 kJ/kg\\P_{4} = 410kPa\\\\s_{4} = s_{3} \\h_{4s} = 470.40kJ/kg\\\\T_{4} = 179.5^{0} C\\\\h_{4} = 689.74 kJ/KG\\\\ The  isentropic  efficiency, n_{T} = \frac{h_{3}-h_{4}  }{h_{3}- h_{4s} }

==\frac{761.54-689.74}{761.54-670.40} \\=\frac{71.8}{91.14} \\=0.788

b. Pump

h_{1} = h_{f} @ 410kPa = 273.01kJ/kg\\v_{1} = v_{f} @ 410kPa = 0.001842 m^{3}/kgw_{p,in} =  \frac{v_{1}(P_{2}-P_{1})   }{n_{p} } \\\\= \frac{0.01842(3250-410)}{0.9} \\\\ =5.81kJ/kg\\h_{2} =h_{1} + w_{p,in}\\          = 273.01+5.81\\           = 278.82 kJ/kg\\\\w_{T,out} = m^{.}  (h_{3} -h_{4} )\\=(305.6)(761.54-689.74)\\=305.6(71.8)\\=21,942kW\\\\

W^{.} _ {P,in} = m^{.} (h_{2} -h_{1}) \\=m^{.}  w_{p,in \\=305.6(5.81)\\\\=1,777kW\\W^{.}  _{net} = W^{.} _{T, out} - W^{.}  _{P,in} \\= 21,942-1,777\\=20,166 kW\\\\HEAT EXCHANGER\\\\Q_{in} = m^{.} _{geo} c_{geo} (T_{in-T_{out} } )\\=555.9(4.18)(160-90)\\=162.656kW\\

c. The thermal efficiency of the cycle  n_{th}  =\frac{W^{.} _{net} }{Q^{._{in} } } \\\\= \frac{20,166}{162,656} \\=0.124\\=12.4%

7 0
3 years ago
Read 2 more answers
A mass of 5 kg of saturated water vapor at 100 kPa is heated at constant pressure until the temperature reaches 200°C.
Alex73 [517]

Answer: you can watch a video on how to solve this question on you tube

6 0
3 years ago
Search and destroy christian
Setler [38]

Answer: ummmm wut?

Explanation:

3 0
3 years ago
Read 2 more answers
A model of living systems as whole entities which maintain themselves through continuous input and output from the environment,
3241004551 [841]

A model of living systems as whole entities which maintain themselves through continuous input and output from the environment, developed by ludwig von bertalanffy is known as Systems theory.

<h3>what are the application of systems theory?</h3>

It is a theoretical framework to understand the working mechanism of an organization.

It is an entity where all the elements necessary to carry out its functions.

A computer is the best  example of showing the mechanism of system theory.

computer is a system which has many smaller sub-systems that have to work in coordinated manner.

These sub-systems are the processor, RAM, motherboard, hard drive and power supply.

Learn more about systems theory , here:

brainly.com/question/28278157

#SPJ4

7 0
2 years ago
Other questions:
  • The natural variation of a process relative to the variation allowed by the design specifications is known as
    15·1 answer
  • g The pump inlet is located 1 m above an arbitrary datum. The pressure and velocity at the inlet are 100 kPa and 2 m/s, respecti
    8·1 answer
  • In the 5 Code of Federal Regulations (C.F.R.), it is recommended that an individual has security awareness training before s/he
    8·2 answers
  • True or False? Duties of the company officials should be discussed
    11·1 answer
  • Which option supports the following scenario?
    14·1 answer
  • Technician A says that squeeze-type resistance spot welding (STRSW) may be used on open butt joints. Technician B says that repl
    14·1 answer
  • When does someone's work on the Internet become copyrighted?
    15·1 answer
  • The pressure at the bottom of an 18 ft deep storage tank for gasoline is how much greater than at the top? Express your answer i
    15·1 answer
  • Is reinforcement needed in a retaining wall
    5·2 answers
  • QUICK ASAP!!!
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!