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 In the above water treatment facility, chemical concentration (mg/gal) within the tank can be considered uniform. The initial
vlada-n [284]

Answer:

0.05 mg / gallon

Explanation:

mass of chemecila coming in per minute = 50*10 = 500 mg/min

at a time t min , M = mass of chemical = 500*t mg

conecntartion of chemecal = 500t/10000 = 0.05 mg / gallon

8 0
3 years ago
the velocity of a particle is given by v=16t^2i+4t^3j+(5t+2k) m/s, where t is in seconds. if the particle is at the origin when
pshichka [43]

Answer:

80.16 m/s^2

at t=2 s

x=42.3 m

y=16 m

z=14 m

Explanation:

solution

The x,y,z components of the velocity are donated by the i,j,k vectors.

v_{x}=16t^{2}  \\v_{y}=4t^{3}\\v_{z}=5t+2

acceleration is a derivative of velocity with respect to time.

a_{x}=\frac{d}{dt} v_{x}=\frac{d}{dt}[16t^{2}]=32t\\a_{y}=\frac{d}{dt} v_{y}=\frac{d}{dt}[4t^{3}]=12t^{2} \\a_{z}=\frac{d}{dt} v_{z}=\frac{d}{dt}[5t+2]=5

evaluate acceleration at 2 seconds

a_{x} =32*2=64m/s^{2}\\ a_{y} =12*2^{2} =48m/s^{2}\\a_{z} =5m/s^{2}

the magnitude of the acceleration is the square root of the sum of the square of each component of the acceleration.

=\sqrt{a_{x}^2 +a_{y}^2+a_{z} ^2 } \\=\sqrt{64^2 +48^2+5 ^2 }\\=80.16m/s^2

position is the integral of velocity with respect to time position at a time can be found by taking by taking the definite intergral of each component.

x=\int\limits {v_{x} } \, dx=\int\limits^2_0 {{16t^2} \, dt=42.7m\\\\y=\int\limits {v_{y} } \, dx=\int\limits^2_0 {{4t^3} \, dt=16m\\\\\\\\\\z=\int\limits {v_{z} } \, dx=\int\limits^2_0 {{5t+2} \, dt=14m\\\\

3 0
3 years ago
(a) A non-cold-worked 1040 steel cylindrical rod has an initial length of 100 mm and initial diameter of 7.50 mm. is to be defor
serg [7]

Answer:

A) 1040 steel is not a possible candidate for this application

B) 35.94%

Explanation:

Initial length = 100 mm =  0.1 m

Initial diameter ( d ) = 7.5 mm = 0.0075 m

Tensile load ( p ) = 18,000 N

Condition : The 1040 steel must not experience plastic deformation or a diameter reduction of more than 1.5 * 10^-5 m

<u>A) would the 1040 steel be a possible candidate for this application</u>

<em>Yield strength of 1040 steel < stress  ( in order to be a possible candidate )</em>

stress = p / A0 = ( 18000 ) / ( \frac{\pi }{4} ) * 0.0075^2

                      = 18,000 / (4.418 * 10^-5 )   =  407.424 MPa

Yield strength of 1040 steel = 450 MPa

stress = 407.424 MPa

∴ Yield strength ( 450 MPa ) > stress ( 407.424 MPa )  

Therefore 1040 steel is not a possible candidate for this application

<u>B) Determine How much cold work would be required to reduce the diameter of the steel to 6.0 mm</u>

Area1 = ( \frac{\pi }{4} ) ( 0.006 )^2 = 2.83 * 10^-5 m^2

therefore % of cold work done = ( A0 - A1 ) / A0  * 100 = 35.94%

6 0
2 years ago
Your study space does not need to be quiet as long as you can ignore any noise coming from the space true or false?
Makovka662 [10]

Answer:

False

Explanation:

When you're studying, you need to make sure that you can focus properly. This means that you shouldn't be hungry or too full and that you should be well-rested, in a quiet room with good lighting and no distractions. Noise is never good when you need to memorize something. Some people can partially ignore it as long as it isn't too loud, but it will begin to bother them eventually. That's why it's better to study in a quiet room.

3 0
2 years ago
Read 2 more answers
. En la facultad de Ingeniería Industrial se realizó una encuesta a 200 personas para saber que lenguaje de programación preferí
GarryVolchara [31]

Answer:

lalalalapumpe

Explanation:

4 0
3 years ago
Other questions:
  • The number of weaving errors in a twenty-foot by ten-foot roll of carpet has a mean of 0.8 What is the probability of observing
    6·1 answer
  • What are the challenges posed by strategic information systems, and how should they be addressed?
    10·1 answer
  • Which of the following is the correct definition of mechanical energy?
    9·2 answers
  • Annie has collected several items from around her house. She is using these objects to investigate which objects are attracted t
    12·1 answer
  • To test the effects of a new fertilizer, 100 plots were divided in half. Fertilizer A is randomly applied to one half, and B to
    13·2 answers
  • A 100-mm-diameter cast Iron shaft is acted upon by a 10 kN.m bending moment, a 8 kN.m torque, and a 150 kN axial force simultane
    9·1 answer
  • Worth 20 points! Please help ASAP!
    5·1 answer
  • g Asbestos is a fibrous silicate mineral with remarkably high tensile strength. But is no longer used because airborne asbestos
    5·1 answer
  • Could you please answer this question clearly?
    11·1 answer
  • Periodic lubrication and oil changes according to manufacturer’s recommendations extend the life of your vehicle, and allow you
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!