Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help me solve in java. public class ScannerMethods { /** * * Return the first int token contained in the provided * Scanner, even

please help me solve in java.

public class ScannerMethods {

/**

*

* Return the first int token contained in the provided

* Scanner, even if non-int tokens precede it. A token is

* any sequence of characters surrounded by whitespace.

* Non-int tokens preceding the first int are discarded.

* If no such int is found, then throw an IllegalArgumentException.

*

* @param scan Scanner containing tokens (at least one int token)

* @return The first int found in the scanner

*/

public static int firstInt(Scanner scan) {

// TODO: Return first int if found

// No int was found

throw new IllegalArgumentException("The Scanner must contain an integer!");

}

/**

*

* Count the number of tokens contained in a Scanner

* of a finite data stream (not from the console).

* All tokens that are counted are discarded from

* the Scanner. Use the Scanner's next method.

*

* @param scan Scanner on finite stream of data

* @return number of tokens in Scanner

*/

public static int countTokens(Scanner scan) {

return -1; // TODO

}

/**

*

* Count number of lines contained in a Scanner

* of a finite data stream (not from the console).

* All lines that are counted are discarded from

* the Scanner. Use the Scanner's nextLine method.

*

* @param scan scan Scanner on finite stream of data

* @return number of lines in Scanner

*/

public static int countLines(Scanner scan) {

return -1; // TODO

}

/**

*

* Take all lines from a Scanner connected to a finite

* data source and store them in an ArrayList in the order

* they are encountered.

*

* @param scan Scanner of finite data stream (not console)

* @return ArrayList of String lines from Scanner

*/

public static ArrayList getLines(Scanner scan) {

return null; // TODO

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

=+Will the assumptions youve made change over time?

Answered: 1 week ago