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
Ainat [17]
3 years ago
9

Assume inputFile is a Scanner object used to read data from a text file that contains a number of lines. Each line contains an a

rbitrary number of words, with at least one word per line. Select an expression to complete the following code segment, which prints the last word in each line. while (inputFile.hasNextLine()) { String word = ""; String line = inputFile.nextLine(); Scanner words = new Scanner(line); while (_________________) { word = words.next(); } System.out.println(word); }
Computers and Technology
1 answer:
anzhelika [568]3 years ago
7 0

Answer:

words.hasNext()

Explanation:

Given the code snippet below:

  1.        while (inputFile.hasNextLine()) {
  2.            String word = "";
  3.            String line = inputFile.nextLine();
  4.            Scanner words = new Scanner(line);
  5.            while (words.hasNext()) {
  6.                word = words.next();
  7.            }
  8.            System.out.println(word); }
  9.    }

We have a inputFile Scanner object that can read data from a text file and we presume the inputFile has read several rows of data from the text file. So long as there is another line of input data available, the outer while loop will keep running. In each outer loop, one line of data will be read and assign to line variable (Line 3). Next, there is another Scanner object, words, which will take the current line of data as input. To get the last word of that line, we can use hasNext() method. This method will always return true if there is another tokens in its input. So the inner while loop will keep running so long as there is a token in current line of data and assign the current token to word variable. The word will hold the last token of current line of data upon exit from the inner loop. Then we can print the output (Line 8) which is the last word of the current line of data.

You might be interested in
4. WiFi and WiMax are used for a high-speed wireless access technology.
nikdorinn [45]

Answer: Wifi and WiMax are used to create wireless network connections.

Explanation: Wifi and WiMax are used to create wireless network connections. Wifi is used to create small networks and used to connect printers, computers, gaming consoles. WiMax uses spectrum to deliver connection to network. WiMax is used to provide internet services such as Mobile Data and hotspots.

8 0
3 years ago
Rules that govern how to communicate online are known as etiquette. netiquette. Internet laws. computer rights.
azamat

Answer:

Explanation:

i think it might be netiquette

7 0
3 years ago
Read 2 more answers
Most of the international operations in a computer use hexadecimal numbering. True Or False
Natalija [7]

Answer:

True

Explanation:

The hexadecimal numbering is the most used numeric system for international operations in a computer, in our daily life we use the decimal system but for the CPU use the byte or octet as a basic unit of memory, we need more than 10 digits, and the hexadecimal system has 16, in addition, the binary system is hard to understand.

8 0
4 years ago
It is possible to have motion in the absence of a force
den301095 [7]
Yes, motion continues after forces are no longer being applied. Otherwise, a ball wouldn't continue to roll after it left your hand.
No, gravitational forces from every piece of matter in the universe affect every other piece of matter in the universe. Gravity cannot be blocked.
6 0
3 years ago
Select the correct answer.
aleksandrvk [35]

Answer:

B.  color and painting tools

Explanation:

5 0
2 years ago
Other questions:
  • The image uses a school of fish to symbolize leadership.
    10·2 answers
  • When using the strcat function, you must be careful not to overwrite the bounds of an array?
    5·1 answer
  • Convert A4B from hexadecimal to binary. Show your work.
    11·1 answer
  • Prompt the user for a character and the height of a right triangle. Then, print a triangle of that height using the character en
    11·1 answer
  • Suppose that L is a sorted list of 1,000,000 elements. To determine whether the x item is in L, the average number of comparison
    14·1 answer
  • It is where your cpu (processor) is installed
    10·2 answers
  • I have no idea how to use the sep and end in Python can someone help me I have a test tomorrow
    13·1 answer
  • What are three ways to protect yourself from identity theft when using your smartphone or computer?.
    15·1 answer
  • Write a recursive decent algorithm for a java while statement, a Javas if statement , an logical/mathematical expression based o
    5·1 answer
  • the set of methods that can be used to acquire, organize, store, manipulate, and transmit information is known as .
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!