I need help with using the Stringtokenizer. I'm not sure if it should be in a class, and called in the main. Or should be in my main program. this is the description : Using StringTokenizer, the program will parse the input file and identify words and integers. Words are notcase sensitive and can only contain letters, apostrophes, hyphens, and digits but must start with a letter. The numbers are a sequence of digits. They can be positive or negative integers. If the number is negative, there is no space between the negative sign, -, and the first digit. A sum will be made form the integers contained in the input file. StringTokenizer methods inline now contains the tokens. A few useful method of the StringTokenizer are: Boolean hasMoreTokens() // test if there are more tokens available from this tokenizer's string. String nextToken() // returns the next token from this string tokenizer. Int countTokens() //calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception code in the main : class main { public static void main(String[] args) throws IOException { IOFile myFilesObj = new IOFile(); int i = 0; // Array index int count = 0; // number of Word objects in words array int sum = 0; // sum of integers // Word[] words = new Word[100]; // Array of word objects StringTokenizer inline; // Stringtokenizer of current line BufferedReader infile; // input file handle PrintWriter outfile; // output file handle myFilesObj.validateNames(args); infile = myFilesObj.openIn(myFilesObj.inputFileName); outfile = myFilesObj.openOut(myFilesObj.outputFileName); } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I need help with using the Stringtokenizer. I'm not sure if it should be in a class, and called in the main. Or should be in my main program. 

this is the description :

Using StringTokenizer, the program will parse the input file and identify words and integers. Words are notcase sensitive and can only contain letters, apostrophes, hyphens, and digits but must start with a letter. The numbers are a sequence of digits. They can be positive or negative integers. If the number is negative, there is no space between the negative sign, -, and the first digit. A sum will be made form the integers contained in the input file.

StringTokenizer  methods

  •  inline now contains the tokens.
  • A few useful method of the StringTokenizer  are:
    • Boolean hasMoreTokens()  // test if there are more tokens available from this tokenizer's string.
    • String nextToken() // returns the next token from this string tokenizer.
    • Int countTokens() //calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception

code in the main :

class main {
 public static void main(String[] args) throws IOException {

  IOFile myFilesObj = new IOFile();

  int i = 0; // Array index
  int count = 0; // number of Word objects in words array
  int sum = 0; // sum of integers
  // Word[] words = new Word[100]; // Array of word objects
  StringTokenizer inline; // Stringtokenizer of current line
  BufferedReader infile; // input file handle
  PrintWriter outfile; // output file handle

  myFilesObj.validateNames(args);

  infile = myFilesObj.openIn(myFilesObj.inputFileName);
  outfile = myFilesObj.openOut(myFilesObj.outputFileName);

 }
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY