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]
3 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]3 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
What is the Microsoft excel window where you work on. And it composed of three worksheet?​
antoniya [11.8K]

Answer:

work book

Explanation:

A work book is a book in MS excel which contains work sheet

4 0
3 years ago
Which of the acronyms listed below refers to a series of basic hardware diagnostic tests performed by the startup BIOS after the
Morgarella [4.7K]

Answer:

POST

Explanation:

  • POST stands for Power On Self test.
  • The process of booting the system involves performing the self test POST.
  • POST involves testing the computer hardware which are required for proper functioning of the computer.
  • If the POST test fails, the computer performs the necessary action required for the proper functioning of the computer.It immediately raises alarm ( beeps ) . Different number of beeps represents different devices which are having trouble.
  • So, option (D) is correct option.
  • Option (A) IDE is not the test. So, option (A) is wrong option.
  • Option (B) POTS is not the test.So, option (B) is wrong option.
  • Option (C) QoS is not the test. So, option (C) is wrong option.
7 0
3 years ago
Megan owns a small neighborhood coffee shop, and she has fifteen employees who work as baristas. All of the employees have the s
nlexa [21]

Answer:

she gives 10 dollars an hour

Explanation:

no

4 0
2 years ago
In this lesson, you learned how to create reports and how to display them in a Web application. You will use the same chinook da
Nimfa-mama [501]

create a report that displays back tge total sales by country

6 0
2 years ago
Write a program that reads in an integer, and breaks it into a sequence of individual digits. Display each digit on a separate l
Montano1993 [528]

Answer:

The program in Python is as follows:

num = int(input())

for i in str(num):

   print(int(i))

Explanation:

This gets input for the number

num = int(input())

This converts the number to string and iterates through each element of the string

for i in str(num):

This prints individual digits

   print(int(i))

4 0
2 years ago
Other questions:
  • If the current through a heater coil is 5 amp and the supply voltage is 120 volts, the coil resistance is A. 0.04 ohm. B. 24 ohm
    6·1 answer
  • What is the key benefit of using RAM in a computer?
    12·1 answer
  • What is the subnet mask ?
    9·2 answers
  • A computer has been stored, uncovered, in a dusty closet for several months. Why might this situation cause the operating system
    13·1 answer
  • True or false there is no relationship between the purpose of the page and the page quality
    13·1 answer
  • Be able to list a technology-based company and discuss whether it enjoys sustainable competitive advantage based on the resource
    13·1 answer
  • Need help with this​
    5·1 answer
  • How do you merge on excel?​
    5·1 answer
  • If you were any type of fnaf charater who would you be and why?
    10·2 answers
  • failed logins or instances of denial of access to restricted files may be indicators of compromise. suggest where records of suc
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!