The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Academic Tokenizer

Posted by Dee Gow on January 17, 2002 at 6:07 PM

I am doing an assigment for java through correspondance where I need to set up a tokenizer to run so it can find whether the person is a Employee or an Academic

Needless to say it will not work and I have no Idea what is wrong as we have no support
If any one can help I would appreciate it
Code Below

import java.io.*;
import java.util.StringTokenizer;

class Employee1
{

protected int setname;
protected double setsalary;

Employee1();
{

setsalary = 0.0;


Employee(int setname, double setsalary)
{
setname = name;
setsalary = salary;
}

void setname(int name)
{
setname = name;
}

void setsalary(double displaysalary)
{
setsalary = displaysalary;
}

double getsalary()
{
return (salary*2);
}


}
class AcademicEmployee extends Employee1
{

final double SURCHARGE = 0.1;
String message;


}

// SET METHODS
void setName(String AcademicEmployee);
{
setname = AcademicEmployee;
}

double setsalary()
{
return (salary * + SURCHARGE);
}

class EmployeeManager
{
public static void main(String[] args) throws IOException
{
// variable declarations used for input
String rawInput;
double displaySalary;
int inQualification;
String setName;

// create a bufferedreader to use for keyboard input


BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

// prompt user to enter academic information in single line
System.out.println("Enter the Academic information in a single line separate each with a space:");


// read in a line of input and tokenise it
StringTokenizer inTokens = new StringTokenizer(stdin.readLine());

// if there are 2 tokens, assume it's a non academic employee
if (inTokens.countTokens() == 2)
{
// parse tokens into correct variable types for constructor
inName = inTokens.nextToken();
inSalary = Double.valueOf(inTokens.nextToken()).doubleValue();


// call constructor to create a AcademicEmployee object
AcademicEmployee = new AcademicEmployee (inName,inSalary);

// use the accessors to retrieve information about the object
// and print to the user
System.out.println("\nName" + order.getName());
System.out.println("\nSalary $ " + order.getSalary());
}
// otherwise, if it had 3 tokens, assume it's Academic Employee
else if (inTokens.countTokens() == 3)
{
// parse tokens into correct variable types for constructor

inName = inTokens.nextToken();
inSalary = Double.valueOf(inTokens.nextToken()).doubleValue();
inQualification = inTokens.nextToken();


// call constructor to create a AcademicEmployee
AcademicEmployee = new AcademicEmployee (inName, inSalary, inQualification);

// use the accessors to retrieve information about the object
// and print to the user
System.out.println("\nName " + order.setName());
System.out.println("\Salary $ " + order.displaySalary());
System.out.println("\n Qualification " + order.setQualication());

}
// otherwise, any other number of tokens is invalid
else
{
System.out.println("Invalid input entered!");
}
}




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us