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
What is 203593^54/38n^7
Snowcat [4.5K]

Answer:

cool

Explanation:

3 0
2 years ago
if when you put your shirt in your pants, your shirt is tucked, does that mean when your shirt is over your pants, your pants ar
Archy [21]

Answer:

confusing, but yes

Explanation:

8 0
2 years ago
Read 2 more answers
python Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month an
kupik [55]

Answer:

month = input("Input the month (e.g. January, February etc.): ")

day = int(input("Input the day: "))

if month in ('January', 'February', 'March'):

season = 'winter'

elif month in ('April', 'May', 'June'):

season = 'spring'

elif month in ('July', 'August', 'September'):

season = 'summer'

else:

season = 'autumn'

if (month == 'March') and (day > 19):

season = 'spring'

elif (month == 'June') and (day > 20):

season = 'summer'

elif (month == 'September') and (day > 21):

season = 'autumn'

elif (month == 'December') and (day > 20):

season = 'winter'

print("Season is",season)

Explanation:

4 0
3 years ago
Select the correct answer.
juin [17]
Orthographic projection, common method of representing three-dimensional objects, usually by three two-dimensional drawings in each of which the object is viewed along parallel lines that are perpendicular to the plane of the drawling.
4 0
2 years ago
An air standard cycle with constant specific heats is executed in a closed system with 0.003 kg of air and consists of the follo
Vsevolod [243]

Answer:

a) Please see attached copy below

b) 0.39KJ

c)  20.9‰

Explanation:

The three process of an air-standard cycle are described.

Assumptions

1. The air-standard assumptions are applicable.

2. Kinetic and potential energy negligible.

3. Air in an ideal gas with a constant specific heats.

Properties:

The properties of air are gotten from the steam table.

b) T₁=290K ⇒ u₁=206.91 kj/kg, h₁=290.16 kj/kg.

P₂V₂/T₂=P₁V₁/T₁⇒ T₂=P₂T₁/P₁ = 380/95(290K)= 1160K

T₃=T₂(P₃/P₂)⁽k₋1⁾/k =(1160K)(95/380)⁽⁰°⁴/₁.₄⁾ =780.6K

Qin=m(u₂₋u₁)=mCv(T₂-T₁)

=0.003kg×(0.718kj/kg.k)(1160-290)K= 1.87KJ

Qout=m(h₃₋h₁)=mCp(T₃₋T₁)

=0.003KG×(1.005kj/kg.k(780.6-290)K= 1.48KJ

Wnet, out= Qin-Qout = (1.87-1.48)KJ =0.39KJ

c)ηth= Wnet/W₍in₎ =0.39KJ/1.87KJ = 20.9‰

7 0
2 years ago
Other questions:
  • A closed, rigid, 0.45 m^3 tank is filled with 12 kg of water. The initial pressure is p1 = 20 bar. The water is cooled until the
    15·1 answer
  • A 5 m deep deposit of sand and silt containing organic layers is to be compacted using explosives placed in the boreholes locate
    13·1 answer
  • Rosbel or Janette lol baakkaaa
    11·2 answers
  • Find the general solution of the equation<br>a) Tan A = 1/√3​
    11·1 answer
  • How to update android 4.4.2 to 5.1 if there isnt any update available​
    15·2 answers
  • The Aluminum Electrical Conductor Handbook lists a dc resistance of 0.01558 ohm per 1000 ft at 208C and a 60-Hz resistance of 0.
    11·1 answer
  • What learning is required to become a mechanical engineer?
    14·1 answer
  • Chandler is working on a school editing project. Because he copied 10 GB of raw footage to his computer, its memory is running l
    11·1 answer
  • A proposed embankment fill requires 7100 ft of compacted soil. The void ratio of the compacted fill is specified as 0.5. Four bo
    10·1 answer
  • In a morphological matrix, which of the following contains the parameters that are essential to a design?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!