Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

Why are bond maturity dates important?

Answered: 1 week ago

Question

identify the main types of research studies in HRM research;

Answered: 1 week ago

Question

decide what data to gather and when;

Answered: 1 week ago