Help with StringTokenizer!
Instructions: Use a loop to process each of the strings in the array and display the last name for each employee followed by a comma, followed by the first name, followed by the weekly pay (see example below. To accomplish this, consider what you must do each time the loop repeats, Each repetition should process the next string in the array, using a StringTokenizer instance that to parse the current array element based on the colon. After extracting the four values from the string. You will need to convert the hours worked to an int and the hourly wage to a double before calculating the weekly wage. Here is how your output should appear:
John Smith: $446.25
any hints greatly appreciated!!:)
My Code:
import java.text.*;
import java.util.*;
import java.util.StringTokenizer;
public class Exam2_3
{
public static void main (String [] args)
{
DecimalFormat currency = new DecimalFormat("$#,##0.00");
String [] employees = {"John:Smith:35:12.75",
"Mary:King:20:22.75",
"Chris:Kennedy:40:15.75",
"Angela:Jones:35:10.75",
"Mark:Smith:35:18.75"};
String firstName, lastName;
int hoursWorked;
double hourlyRate, weeklyPay;
}
}