
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
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);
}
}

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- In Python: Read a string as input from user and print the number of Uppercase alphabets present in the string in output.arrow_forwardWrite a Regular expression that check whether a string contains an Vowel or not? You have also include the driver code in Java Language. Your driver code should take string from the user.arrow_forwardThe loop below is intended to collect all characters that occur more than once in a given string. When you try it out with a string such as “Mississippi”, you will note that that letters that occur three or more times are collected more than once. Modify the loop so that each repeated letter is collected exactly once. For example, when s is “Mississippi”, result should be “si” and not “sissii” Only allowed to edit code in the /* Your code goes here */ portion. Thanks for the help!arrow_forward
- 3 – Write a python program that prompt the user to enter a string and count the number of words and characters in that string without using built-in methods.arrow_forwardIm stuck on this java code. The code is supposed to ask user for a string. Characters that are number, are doubled and replaced with the sum. The characters that are upper are replaced with lower and lower are replaced with upper. It should keep asking user for string until user input Q to end the program. example 1: original: 3rD converted: 6Rd ex 2: original: 6sJ converted: 3Sj (when a value is doubled and its than 9, the two digits are added. so 6 * 2 is 12. And then add the two digits. so 1 + 2 = 3.) I'm having problem with the code that its not reading where it replace the lower to upper and vice versa. this is my code so far: import java.util.Scanner;public class Convert {public static void main(String[] args) {Scanner input = new Scanner(System.in);String original, converted;while (true) {System.out.print("Original String (input):");original = input.nextLine();if (original.equals("q") || original.equals("Q")) {break;}char[] chars = original.toCharArray();for (int i = 0; i <…arrow_forwardI need help with Java code. I'm not sure how to start...arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





