View Single Post
  #9 (permalink)  
Old 12-12-2008, 07:13 AM
ookie833 ookie833 is offline
Member
 
Join Date: Nov 2008
Posts: 9
Rep Power: 0
ookie833 is on a distinguished road
Default hmm...
ok I can parse the array with the StringTokenizer.
But now I am stumped on how to iterate through the array with a loop.
This is my code but it only displays the first string 5 times instead of all five strings.

I added to more variables...

String strHoursWorked;
String strHourlyRate;

for (int index=0; index < employees.length; index++)
{
StringTokenize employee=new StringTokenizer(employee[0]);
firstName=(employee.nextToken(":");
lastName=(employee.nextToken(":");
strHoursWorked=(employee.nextToken(":");
strHourlyRate=(employee.nextToken(":");

hoursWorked=Integer.parseInt(strHoursWorked);
hourlyRate=Double.parseDouble(strHourlyRate);

weeklyPay=hoursWorked * hourlyRate;
}
System.out.println(firstName + " " + lastName + ":" + currency.format(weeklyPay));


Any ideas on what I am doing wrong with this loop???
Reply With Quote