Results 1 to 2 of 2
Thread: String Tokenizer HELP!
- 11-09-2011, 12:36 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 1
- Rep Power
- 0
String Tokenizer HELP!
How do I plug the right information in to find regular hours and overtime hours worked of a person for five days? I just don't know what variables and information is to go where. The template is below. Like what would I put in for num1 or avg or grade?
import java.io.*;
import java.util.StringTokenizer;
public class W
{
private static FileInputStream inFile;
private static InputStreamReader inReader;
private static BufferedReader reader;
private static StringTokenizer strTkn;
private static String line,word;
private static int num1, num2,num3,num4,num5,grade, total;
private static double avg;
public static void main (String args[]) throws IOException
{
initFile();
getData();
calcTotal();
printResults();
// Closing data file
inFile.close();
}
// Preparing for input
public static void initFile() throws IOException
{
inFile = new FileInputStream ("C://!!VHSAPCSData\test.txt");
inReader = new InputStreamReader(inFile);
reader = new BufferedReader(inReader);
}
public static void getData() throws IOException
{
line = reader.readLine();
System.out.println ("data line = " + line );
System.out.println();
strTkn = new StringTokenizer(line);
word = strTkn.nextToken();
grade = Integer.parseInt(strTkn.nextToken());
avg = Double.parseDouble(strTkn.nextToken());
num1 = Integer.parseInt(strTkn.nextToken());
num2 = Integer.parseInt(strTkn.nextToken());
num3 = Integer.parseInt(strTkn.nextToken());
num4 = Integer.parseInt(strTkn.nextToken());
num5 = Integer.parseInt(strTkn.nextToken());
}
public static void calcTotal()
{
total = num1 + num2 + num3;
}
public static void printResults()
{
System.out.println("Separated data line :");
System.out.println(word);
System.out.println (grade);
System.out.println (avg);
System.out.println(num1);
System.out.println(num2);
System.out.println(num3);
System.out.println(num4);
System.out.println(num5);
System.out.println("sum of numbers = " + total);
}
}
- 11-10-2011, 08:01 AM #2
Member
- Join Date
- Nov 2011
- Posts
- 1
- Rep Power
- 0
Similar Threads
-
String Tokenizer
By udit ajmera in forum Java SoftwareReplies: 0Last Post: 03-05-2011, 06:35 PM -
Need help with string tokenizer
By ShortIt in forum New To JavaReplies: 1Last Post: 02-18-2011, 07:04 PM -
String Tokenizer
By sumaih in forum Java GamingReplies: 2Last Post: 08-21-2010, 03:23 PM -
String Tokenizer
By hussainian in forum Advanced JavaReplies: 1Last Post: 03-16-2010, 08:58 AM -
string tokenizer
By twinytwo in forum New To JavaReplies: 2Last Post: 03-26-2009, 02:10 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks