Question: Download and import the LabDocumentationGiven.zip project. Rename the project to: sidd 4 7 9 0 _ l 0 1 This project contains a ScannerTest class

Download and import the LabDocumentationGiven.zip project. Rename the project to:
sidd4790_l01
This project contains a ScannerTest class and a Main class to test the ScannerTest class. Using the Scanner methods listed in the Java API documentation, alter the ScannerTest class to do the following: package cp213;
import java.util.Scanner;
/**
* Class to demonstrate the use of Scanner with a keyboard and File objects.
*
* @author your name here
* @version 2022-01-08
*/
public class ScannerTest {
/**
* Count lines in the scanned file.
*
* @param source Scanner to process
* @return number of lines in scanned file
*/
public static int countLines(final Scanner source){
int count =0;
// your code here
return count;
}
/**
* Count tokens in the scanned object.
*
* @param source Scanner to process
* @return number of tokens in scanned object
*/
public static int countTokens(final Scanner source){
int tokens =0;
// your code here
return tokens;
}
/**
* Ask for and total integers from the keyboard.
*
* @param source Scanner to process
* @return total of positive integers entered from keyboard
*/
public static int readNumbers(final Scanner keyboard){
int total =0;
// your code here
return total;
}
Update the countLines method to count the number of lines in a file. The main method opens the source code file as a File object to use for testing:
File file = new File("src/cp213/ScannerTest.java");
Scanner source = new Scanner(file);
Note that Java looks for data files in the project's root folder. Note also that Java may wish to throw an Exception if the file cannot be found.
Update the countTokens method to count the number of tokens in the file. A token is anything that is surrounded on both sides by a space character - a space, tab, end of line, or end of file/string. Each word in this paragraph is a separate token.
Update the readNumbers method to quit only when a q is entered and to reject all other non-integers with the error message: not an integer . Example:
5
8
what?
'what?' is not an integer or 'q'.
how about 7?
'how about 7?' is not an integer or 'q'.
7
q
For the programs you just finished writing include the following documentation:
Author of the class.
Description of the class.
Description of each method.
Generate javadoc for these classes using Eclipse.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!