Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Quick Project help

My question is how would I incorporate the StringTokenizer in this code so that I have an input from a .txt file rather than having an input from the user?
The .txt file has this in it:

Kermit D. Frogge 17.25 5.25 0.0 8.0 1.5 8.0 2.25 7.75 0.0 8.0 2.0

(The name of the Employee is Kermit D. Frogge; 17.25 is the pay rate; 5.25 is the regular hours work; 0.0 is the overtime hours; 8.0 is regular hours worked; 1.5 is the overtime hours and so on and so on..Any help at all would be greatly appreciated..I'm just looking for help with it not for the answer.)

import TerminalIO.*;

public class Project34 {

public static void main (String [] args) {
KeyboardReader reader = new KeyboardReader ();

String emp;
double rate;
int hours;
int overtime;

System.out.print ("Enter Employee ID: " );
emp = reader.readLine();

System.out.print ("Enter Employee Hourly Wage: ");
rate = reader.readDouble();

System.out.print ("Enter Employee Weekly Hours: ");
hours = reader.readInt();

System.out.print ("Enter Employee Overtime Hours: ");
overtime = reader.readInt();

double overtimehours;

overtimehours = ((1.5 * overtime + hours) * (rate));

System.out.print ("Your Total Pay for the week is:$ ");
System.out.print (overtimehours);
}

}
[1444 byte] By [AndyB5073] at [2007-11-11 11:58:41]
# 1 Re: Quick Project help
I edited it..any help would be great
AndyB5073 at 2007-11-11 22:30:30 >
# 2 Re: Quick Project help
The best Class (in my opinion) for reading input is the Scanner class. If you know the structure of your input file, you can easily permit the processing of properly formatted (int, float, String, etc.) data.
nspils at 2007-11-11 22:31:30 >