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
Nowadays power supply on board ship is determine low and high voltage. From what range low & high voltage is being determine
zlopas [31]

Any Voltage used on board a ship if less than 1kV (1000 V) then it is called as LV (Low Voltage) system and any voltage above 1kV is termed as High Voltage. Typical Marine HV systems operate usually at 3.3kV or 6.6kV.

Explanation:

trust

6 0
2 years ago
A jetliner flying at an altitude of 10,000 m has a Mach number of 0.5. If the jetliner has to drop down to 1000 m but still main
andreev551 [17]

Answer

Assuming

At 10000 m height temperature T = -55 C = 218 K

At 1000 m height temperature T = 0 C  = 273 K

\dfrac{V_1}{C_1} =\dfrac{V_2}{C_2} = 0.5

R = 287 J/kg K

C_1 = \sqrt{\gamma RT_1} = \sqrt{1.4\times 287\times 218} = 295 m/s

C_2 = \sqrt{\gamma RT_2} = \sqrt{1.4\times 287\times 273} = 331 m/s

V_2 = \dfrac{V_1}{C_1}\timesC_2

V₂ = V₁ ×1.1222

V₁ = 0.5 × C₁ = 0.5 × 295 = 147.5 m/s

V₂ = 1.1222 ×  147.5 = 165.49 m/s

so, the jetliner need to increase speed by ( V₂ -V₁  )

= 165.49 - 147.5

= 17.5 m/s

6 0
4 years ago
The pump of a water distribution system is powered by a 15-kW electric motor whose efficiency is 90 percent. The water flow rate
wariber [46]

Answer:

Mechanical power of pump is 74.07%.    

Explanation:

Power of motor = 15 KW

Efficiency of motor= 90%

So the actual power(P) supplied by motor = 0.9 x 15 KW

P=13.5 KW

Water flow rate = 50 L/s

Volume flow rate = 50 L/s

We know that

1000\ L/s=1\ m^3/s

So

Volume\ flow \rate =0.05\ m^3/s

We know that pump is an open system and work input for open system can be calculated as

W=VΔP

ΔP is the pressure difference

V is the volume flow rate

So by putting the values

W=0.05 (300-100)            (here ΔP=300 - 100=200 KPa)

W=10 KW    

So mechanical power of pump

\eta =\dfrac{W}{P}        

\eta =\dfrac{10}{13.5}    

η =0.7407

Mechanical power of pump is 74.07%.    

6 0
3 years ago
Three identical fatigue specimens (denoted A, B, and C) are fabricated from a nonferrous alloy. Each is subjected to one of the
Law Incorporation [45]

Answer:

B A and C

Explanation:

Given:

Specimen         σ_{max}                      σ_{min}

A                       +450                      -150

B                       +300                      -300

C                       +500                      -200

Solution:

Compute the mean stress

σ_{m} =  (σ_{max}  +  σ_{min})/2

σ_{mA} =  (450 + (-150)) / 2

       =  (450 - 150) / 2  

       = 300/2

σ_{mA} = 150 MPa

σ_{mB}  = (300 + (-300))/2

        = (300 - 300) / 2

        = 0/2  

σ_{mB}  = 0 MPa

 

σ_{mC}  = (500 + (-200))/2

        = (500 - 200) / 2

        = 300/2

σ_{mC}  = 150 MPa  

Compute stress amplitude:

σ_{a} =  (σ_{max}  -  σ_{min})/2    

σ_{aA} =  (450 - (-150)) / 2

       =  (450 + 150) / 2

       = 600/2

σ_{aA} = 300 MPa

σ_{aB} =  (300- (-300)) / 2

       =  (300 + 300) / 2

       = 600/2

σ_{aB}  = 300 MPa

σ_{aC}  = (500 - (-200))/2

        = (500 + 200) / 2

        = 700 / 2

σ_{aC}   = 350 MPa

From the above results it is concluded that the longest  fatigue lifetime is of specimen B because it has the minimum mean stress.

Next, the specimen A has the fatigue lifetime which is shorter than B but longer than specimen C.

In the last comes specimen C which has the shortest fatigue lifetime because it has the higher mean stress and highest stress amplitude.

7 0
4 years ago
THEME: What is the impact of technology on architecture?
abruzzese [7]

Answer:

With increased technological knowledge and consequent decreased factors of ignorance, the structures have less inert masses and therefore less need for such decoration. This is the reason why the modern buildings are plainer and depend upon precision of outline and perfection of finish for their architectural effect.

8 0
3 years ago
Other questions:
  • Can time bend? How many day are in a year? Am I stupid? Can I power something with lemons?
    9·2 answers
  • Injection melding is a process that
    11·1 answer
  • The Molybdenum with an atomic radius 0.1363 nm and atomic weight 95.95 has a BCC unit cell structure. Calculate its theoretical
    15·1 answer
  • userInput = scnr.nextLine(); firstLetter = scnr.nextLine().charAt(0); if ( = firstLetter ) { System.out.println("Found match: "
    6·1 answer
  • Does the Diesel engine have engine knock or detonation problem? Why?
    6·1 answer
  • Is the gap store an example of commercial construction? Yes or no
    10·1 answer
  • Which characteristic would atoms of a ferromagnetic material have?A. A lack of electrons B. North and south poles C. A temporary
    9·1 answer
  • Which option identifies what would be best to use to illustrate Pablo’s ideas in the following scenario?
    14·1 answer
  • QUESTION 1
    6·1 answer
  • If you are being tailgated and need to make a stop, you should
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!