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
Who would be a tippee for purposes of insider trading? a. a janitor who gathers information by reading files on corporate counse
vesna_86 [32]

Answer:

Option A is correct.

Explanation:

A janitor that collects data through reviewing reports on a business counsel's desk could be a tippee for insider trading activities.

Probably, the justification for insider trading remains wrong being that it offers each insider the undue benefit on and around the marketplace, gets the insider's preferences beyond them for which they assume the trustee responsibility, as well as enables the insider to unfairly manipulate the cost of the inventory of a business.

So, the following are the reason the other options are not correct according to the given scenario.

3 0
3 years ago
(EASY)
AnnyKZ [126]
If you go to a college website you will see the it has .edu in the URL extensions.
3 0
2 years ago
Read 2 more answers
When would you use a composite primary key? Group of answer choices
vichka [17]

Answer:

A. Multi-field attributes

B. A ternary relationship

C. A unary relationship

6 0
2 years ago
Read 2 more answers
Give the name and the syntax of the HTML Tag which is <br><br>used for creating a Hypertext Link.​
Annette [7]

Answer:

<a href="enter_site_url_here">Click here to visit site!</a>

Explanation:

href is the link that the element is going to point towards. Meaning it's going to direct the end-user to that site. "Click here to visit site!" is the text that the element is going to say, and that text will have an underline. So it's best to keep it short as you don't want <u>something like this happening on your site</u>.

I'd stick with the classic "here" as the text and have the text before-hand say "Click" and after-hand say " to visit site X" with X being the site name. Or, something along those lines.

8 0
2 years ago
In a linux script, the line ____ is important because it identifies the file as a script.
igor_vitrenko [27]
The closest line to that would be the first line:


#!/bin/bash

echo "Hello World!"


BTW, the "#!" is referred to as a she-bang. When those are the first characters executed, the (requires an absolute path) program that follows is launched, and the rest of this file is given to it as data. To run this like a program, the execute permissions need to be set ( chmod 0755 script.sh ).
8 0
2 years ago
Other questions:
  • What is the purpose of lookup tables in spreadsheet software
    13·2 answers
  • Networking Gadgets, Inc. currently employs eight people but plans to hire 10 more in the next four months. Users will work on mu
    10·1 answer
  • What does the following code output? System.out.println((5+20 + 5)<br> * (10 / 10))
    9·1 answer
  • A type of backlight technology most commonly used in modern laptop devices is called____________.
    9·1 answer
  • Is 5g harmful to the body ?
    9·2 answers
  • Write two cin statements to get input values into birthMonth and birthYear. Then write a statement to output the month, a dash,
    7·1 answer
  • A _____________ is designed for a individual user.
    9·1 answer
  • The cat store needs your help! The base class Animal has private fields animalName, and animalAge. The derived class Cat extends
    9·1 answer
  • 6. The following is a dump of a DATA chunk in hexadecimal format. 00000015 00000005 0003000A 00000000 48656C6C 6F000000 a. Is th
    7·1 answer
  • Frank enters "1" in the field for postal code. What is frank most likely trying to do?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!