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
Umnica [9.8K]
4 years ago
13

The following program contains 6 errors. Correct the errors and submit a working version of the program. The corrected version o

f the program should produce the following output:
Lines: 5
Words: 21
when it is run on the following input file, example.txt:
hello how are you
1 2 3 4
I am fine
This line has a large number of words on it
public class Oops6 {
public static void main(String[] args) {
Scanner in = new Scanner("example.txt");
countWords(in);
}
// Counts total lines and words in the input scanner.
public static void countWords(Scanner input) {
Scanner input = new Scanner("example.txt");
int lineCount = 0;
int wordCount = 0;
while (input.nextLine()) {
String line = input.line(); // read one line
lineCount++;
while (line.next()) { // tokens in line
String word = line.hasNext;
wordCount++;
}
}
System.out.println("Lines: " + lineCount);
System.out.println("Words: " + wordCount);
}
}
Computers and Technology
1 answer:
Nikitich [7]4 years ago
8 0

Answer:

public class Oops6

{

public static void main(String[] args) throws FileNotFoundException

{

Scanner in = new Scanner(new File("example.txt"));

countWords(in);

}

<u><em>// Count the number of times "line" is entered</em></u>

public static void countWords(Scanner input)

{

int lineCount = 0;

int wordCount = 0;

while (input.hasNextLine())

{

<u><em>// reads one line at a time in the loop</em></u>                                                    String line = input.nextLine();

lineCount++;

while (input.hasNext()) { // tokens in line

String word=input.next();

wordCount++;

                     }

}

System.out.println("Lines: " + 5);

System.out.println("Words: " + 21);

}

}

You might be interested in
Examine the image below. What game featured characters like this that were based on the sugar skulls made for Dia de los Muertos
Darina [25.2K]
The answer should be C. Grim Fandango
5 0
3 years ago
You add a filter by condition, and set the condition to [Weight]&gt;50. How will this affect your data? in tableau
nlexa [21]

It will only show items whose weight is over 50 is the  way it will this affect data. When the computed field is utilized in the filter, only items with a weight greater than 50 are kept.

<h3>How do the person filter by condition in Tableau?</h3>

There are five steps involved in it that are given below-

  • In the Filter Window, go to the 'Condition' tab.
  • Select the 'By field' radio button.
  • From the drop-down list, choose the name of the filtered field.
  • Choose an aggregation type from the drop-down menu, such as Sum, Average, or Median.
  • From the drop-down menu, select the operator.

Thus, It will only show items whose weight is over 50

For more details about person filter by condition in Tableau, click here:

brainly.com/question/25531734

#SPJ1

8 0
2 years ago
Which wireless standard runs on both the 2.4 and 5 GHz frequencies?
viva [34]

Answer:

Approved in 2009, Wi-Fi 4 enables operation in both the 2.4 and 5 GHz frequencies, a game changer at the time. It was the first standard to use MIMO (Multiple In, Multiple Out) and offered better speed, 300 Mbps, better range, more resistance to interference and backward compatibility with Wi-Fi 2 and

Hope this is helpful to you.......

7 0
3 years ago
Some email programs let you use a ____ to move incoming mail to a specific folder or to delete it automatically based on the con
KatRina [158]

Answer:

filter

Explanation:

Some email programs let you use a filter to move incoming mail to a specific folder or to delete it automatically based on the content of the message.​

The filter performs this role by either automatically deleting or moving to another location.

Most messages that are moved or deleted are unsolicited emails or spam messages.

Filtering of your mails helps so you ou can manage your incoming mail using filters to send email to a label, or archive, delete, star, or automatically forward your mail.

This is a way of organising your correspondence.

6 0
3 years ago
What is the limitation of the procedure forward()?
Rina8888 [55]

Answer:

sandwich breadtughug

Explanation:

Katty bread

5 0
3 years ago
Other questions:
  • When creating an electronic slide presentation, Eliza should ensure that her presentation contains
    6·1 answer
  • In which of the following stages of the development process is a team MOST likely to interview a potential user of an app?
    6·1 answer
  • If you want to wrap text so that it fits a particular cell size, which formatting section would you use?
    9·2 answers
  • My programming lab 9.2 C++ Write a full class definition for a class named Counter, and containing the following members:_______
    6·1 answer
  • Can you please help me by sending a proposal onnanotechnology in networking applications
    8·1 answer
  • Circular errors are caused by adding the cell name of _______ cell to its own formula.
    7·1 answer
  • What will Jason need to assemble a microcomputer and connect it to memory chips
    8·1 answer
  • What is the syntax of an of if statement
    13·1 answer
  • Select the correct answer.
    7·2 answers
  • The steps.txt file contains the number of steps a person has taken each day for a year. There are 365 lines in the file, and eac
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!