0% found this document useful (0 votes)
10 views

Java Token

This document demonstrates how to use the StringTokenizer class in Java to tokenize a string separated by semicolons into individual tokens. It takes staff data as a single string separated by semicolons, uses StringTokenizer to split it into tokens for the staff ID, name, department, phone number and income. It counts how many staff incomes are over 5000 and prints the total. It also defines a Staff class to likely store the tokenized staff data in objects.

Uploaded by

yuukiai99
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Java Token

This document demonstrates how to use the StringTokenizer class in Java to tokenize a string separated by semicolons into individual tokens. It takes staff data as a single string separated by semicolons, uses StringTokenizer to split it into tokens for the staff ID, name, department, phone number and income. It counts how many staff incomes are over 5000 and prints the total. It also defines a Staff class to likely store the tokenized staff data in objects.

Uploaded by

yuukiai99
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

StringTokenizer

import java.util.StringTokenizer;
class staffApp {
public static void main(String args[]) {
Scanner inp = new Scanner(System.in);
int go = 1, bil = 0;

while(go==1) {
System.out.print("\nEnter[staffID;staffName;staffDp
mt;staffPhoneNo;staffIncome]");
String data = inp.next();

StringTokenizer token = new


StringTokenizer(data,";");
String staffID = token.nextToken();
String staffName = token.nextToken();
String staffDpmt = token.nextToken();
String staffPhoneNo = token.nextToken();
String staffIncome = token.nextToken();
double sI =
Double.parseDouble(staffIncome);

if(income > 5000)


bil++;

System.out.println("Stop = 0, Continue =
Otherwise");
go = inp.nextInt();
}

System.out.println("…" + bil);
}
}

class Staff{
private String name;
private String dpmt;
private int totYears;
// all necessary methods
}

You might also like