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
Can you solve this question​
Alecsey [184]

Answer:

eojcjksjsososisjsiisisiiaodbjspbcpjsphcpjajosjjs ahahhahahahahahahahahahahahahhhahahahaahahhahahahahaahahahahaha

6 0
2 years ago
Read 2 more answers
What is the mechanical advantage of a pulley with 3 support ropes?
snow_tiger [21]

Answer:

The mechanical advantage is 3 to 1

Explanation:

A frictionless pulley with three support ropes carries equal tension on each of the ropes thus;

Tension in each pulley rope = T

Total tension in the 3 ropes = 3 × T = 3·T

Direction of the tension forces on each rope = Unidirectional

Total force provided by the 3 ropes = 3·T

Therefore, a force, T, applied at the end of the rope will result in a lifting force of 3·T

Hence, the mechanical advantage = 3·T to T which is presented as follows;

Mechanical \ advantage = \dfrac{3 \cdot T}{T}  = \dfrac{3}{1}

The mechanical advantage = 3 to 1.

5 0
3 years ago
What is one thing a person should do to stay safe when exercising
elixir [45]
Staying hydrated at all times
7 0
3 years ago
Read 2 more answers
One method that is used to grow nanowires (nanotubes with solid cores) is to initially deposit a small droplet of a liquid catal
7nadin3 [17]

Answer: maximum length of the nanowire is 510 nm

Explanation:

 

From the table of 'Thermo physical properties of selected nonmetallic solids at At T = 1500 K

Thermal conductivity of silicon carbide k = 30 W/m.K

Diameter of silicon carbide nanowire, D = 15 x 10⁻⁹ m  

lets consider the equation for the value of m

m = ( (hP/kAc)^1/2 )  = ( (4h/kD)^1/2 )  

m =  ( ((4 × 10⁵)/(30×15×10⁻⁹ ))^1/2 ) = 942809.04    

now lets find the value of h/mk    

h/mk = 10⁵ / ( 942809.04 × 30) =  0.00353

lets consider the value θ/θb by using the equation

θ/θb = (T - T∞) / (T - T∞)

θ/θb =  (3000 - 8000) / (2400 - 8000)

= 0.893

the temperature distribution at steady-state is expressed as;

θ/θb = [ cosh m(L - x) + ( h/mk) sinh m (L - x)]   / [cosh mL+  (h/mk) sinh mL]

θ/θb = [ cosh m(L - L) + ( h/mk) sinh m (L - L)]   / [cosh mL+  (h/mk) sinh mL]

θ/θb = [ 1 ]  / [cosh mL+  (h/mk) sinh mL]

so we substitute

0.893 =  [ 1 ]  / [cosh (942809.04 × L) +  (0.00353) sinh (942809.04 × L)]

L = 510 × 10⁻⁹m

L = 510 nm

therefore maximum length of the nanowire is 510 nm

4 0
3 years ago
A person is planning a bungee jump from a 40 meter high bridge. Under the bridge is a river with crocodiles, so the person does
Nonamiya [84]

Answer:

a. l = 19.7m, b. 18.55m, c. Impact Force = 3889.84 N

Explanation:

The total energy of the system when the person is at top of the bridge is

Potential energy = mgh, Kinetic energy = 0

The total energy of the  system when the person reaches just above the surface

Potential energy = 0, Kinetic energy = 0, Spring energy = ½ K X2, where k is the spring constant and X is the deflection

Applying conservation of energy

mgh = 0 + 0 + ½ K X²

80 x 9.81 x 40 = ½ (3600/l) X²

31392 = ½ (3600/l) X²

We can also conclude that

l+ X + 1.75 = 40

l + X = 38.25

a. <u>Substitute the value of x from above into the energy conversion expression</u>

31392 = ½ (3600/l)(38.25 - l)²

31392 x 2/3600 = (38.25 + l² – 2l(38.25))/l

17.44l = l2 – 76.5l + 38.25²

l² – 76.5l – 17.44l +1463.0625 = 0

Solving for l we get

L = 19.7

Hence, length of the rope is 19.7m

b. <u>The deflection is calculated by using the relation between l and X</u>

L + X = 38.25

X = 38.25 – 19.7 = 18.55m

c. <u>The impact force is calculated using the impact force formula which relates the impact force with the deflection</u>

F = KX

F = (3600/l) . X

F = (3600/19.7) . (18.55) = 3889.84 N

Thus, the impact force is 3889.84 N

3 0
3 years ago
Other questions:
  • Which of the following describes what occurs when energy is lost in efficient transformation?
    14·1 answer
  • A banked highway is designed for traffic moving at v = 88 km/h. The radius of the curve r = 314 m. show answer No Attempt 50% Pa
    5·2 answers
  • A flat-plate solar collector is 2 m long and 1 m wide and is inclined 60o to the horizontal. The cover plate is separated from t
    13·1 answer
  • A common process for increasing the moisture content of air is to bubble it through a column of water. The air bubbles are assum
    13·1 answer
  • What are wheel cylinders used for?
    6·1 answer
  • If the driver gear has 5 teeth and the driven gear has 10 teeth,what is the gear ratio?​
    13·2 answers
  • Identify renewable energy sources you will propose. Explain the key elements to your solution and the basic technical principles
    5·1 answer
  • Why is engineering profession important ​
    11·1 answer
  • I need to solve for d
    11·2 answers
  • 1) Plastics that soften when heated,harden when cooled, and then can be heated and softened many times
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!