Help in java program.i cnt solve the need of this question.question inside.

Create a class named Employee. Includes data members for Employee class :
Data member     = Data type
Employee id     = String
Employee name     = String
Icno     = String
Gender     = Char
Date of birth     = String
Address     = String
Commencing Date     = String
Department     = String
Position     = String
Salary     = Double
Include any relevant methods for example constructor that can perform initialization for all data fields, accessor methods that return each of data field values and mutator method to set values into the data fields. Use a constructor to set each Employee id to 99999 upon object creation.
Write another java application named EmployeeDb. Declare an array of three Employee objects.
Your program should be able to perform the following functions:
(a)     Prompt user to enter three Employees� information from the console and store data in an array
(b)     Search an employee by name.
(c)     Display all employee information by using a loop.
You are NOT required to save records into any text file.
the code i have done
public class Employee
     //declaration of private instance variables
     private String employee_id;
     private String employee_name;
     private String ic_no;
     private char gender;
     private String date_of_birth;
     private String address;
     private String commencing_date;
     private String department;
     private String position;
     private double salary;
     /*constructor prototype
     Employee(String, String, String, char, String, String, String, String, String, double);
     //constructor - Employee(String, String, String, char, String, String, String, String, String, double); function
public Employee()
     this.employee_id = "99999";
     this.employee_name = "name";
     this.ic_no = "ic";
     this.gender = 'g';
     this.date_of_birth = "dob";
     this.address = "add";
     this.commencing_date = "cd";
     this.department = "dept";
     this.position = "post";
     this.salary = 0.00;
public Employee(String id, String name, String ic, char gen, String dob, String add, String cd, String dept, String post, double sal)
     this.employee_id = id;
     this.employee_name = name;
     this.ic_no = ic;
     this.gender = gen;
     this.date_of_birth = dob;
     this.address = add;
     this.commencing_date = cd;
     this.department = dept;
     this.position = post;
     this.salary = sal;
/*public setters function prototypes
     public void setEmployee_id(String);
     public void setEmployee_name(String);
     public void setIc_no(String);
     public void setGender(char);
     public void setDate_of_birth(String);
     public void setAddress(String);
     public void setCommencing_date(String);
     public void setDepartment(String);
     public void setPosition(String);
     public void setSalary(double);
public getters function prototypes
     public String getEmployee_id();
     public String getEmployee_name();
     public String getIc_no();
     public char getGender();
     public String getDate_of_birth();
     public String getAddress();
     public String getCommencing_date();
     public String getDepartment();
     public String getPosition();
     public double getSalary();
//setters - setEmployee_id(String); function
public void setEmployee_id(String id)
     this.employee_id = id;
//setters - setEmployee_name(String); function
public void setEmployee_name(String name)
     this.employee_name = name;
//setters - setIc_no(String); function
public void setIc_no(String ic)
     this.ic_no = ic;
//setters - setGender(char); function
public void setGender(char gen)
     this.gender = gen;
//setters - setDate_of_birth(String); function
public void setDate_of_birth(String dob)
     this.date_of_birth = dob;
//setters - setAddress(String); function
public void setAddress(String add)
     this.address = add;
//setters - setCommencing_date(String); function
public void setCommencing_date(String cd)
     this.commencing_date = cd;
//setters - setDepartment(String); function
public void setDepartment(String dept)
     this.department = dept;
//setters - setPosition(String); function
public void setPosition(String post)
     this.position = post;
//setters - setSalary(double); function
public void setSalary(double sal)
     this.salary = sal;
//getters - getEmployee_id(); function
public String getEmployee_id()
     return employee_id;
//getters - getEmployee_name(); function
public String getEmployee_name()
     return employee_name;
//getters - getIc_no(); function
public String getIc_no()
     return ic_no;
//getters - getGender(); function
public char getGender()
     return gender;
//getters - getDate_of_birth(); function
public String getDate_of_birth()
     return date_of_birth;
//getters - getAddress(); function
public String getAddress()
     return address;
//getters - getCommencing_date(); function
public String getCommencing_date()
     return commencing_date;
//getters - getDepartment(); function
public String getDepartment()
     return department;
//getters - getPosition(); function
public String getPosition()
     return position;
//getters - getSalary(); function
public double getSalary()
     return salary;
//class ended
import java.io.*;
public class EmployeeDb
     //declaration of private instance variables
     private String employee_id;
     private String employee_name;
     private String ic_no;
     private char gender;
     private String date_of_birth;
     private String address;
     private String commencing_date;
     private String department;
     private String position;
     private double salary;
     public static void main(String args[]) throws IOException
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          int i;
          Employee [] empRec = new Employee[3] ;
          String [] emp = new String [10];
          for(i=0; i<empRec.length; i++)
               empRec= new Employee();
               System.out.print("\n");
               i+=1;
               System.out.print("employee record number "+ i +"\n");
               System.out.print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
               System.out.print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
               System.out.print("\n");
               System.out.print("Enter employee id : \n");
               emp[0] = br.readLine();
               System.out.print("Enter employee name : \n");
               emp[1] = br.readLine();
               System.out.print("Enter employee ic number : \n");
               emp[2] = br.readLine();
               System.out.print("Enter employee gender : \n");
               emp[3] = br.readLine();
               System.out.print("Enter employee date of birth : \n");
               emp[4] = br.readLine();
               System.out.print("Enter employee address : \n");
               emp[5] = br.readLine();
               System.out.print("Enter employee commencing date: \n");
               emp[6] = br.readLine();
               System.out.print("Enter employee department : \n");
               emp[7] = br.readLine();
               System.out.print("Enter employee position : \n");
               emp[8] = br.readLine();
               System.out.print("Enter employee salary : \n");
               emp[9] = br.readLine();
          for(i=0; i<empRec.length; i++)
               System.out.println(empRec[i].getEmployee_id());
               System.out.println(empRec[i].getEmployee_name());
               System.out.println(empRec[i].getIc_no());
               System.out.println(empRec[i].getGender());
               System.out.println(empRec[i].getDate_of_birth());
               System.out.println(empRec[i].getAddress());
               System.out.println(empRec[i].getCommencing_date());
               System.out.println(empRec[i].getDepartment());
               System.out.println(empRec[i].getPosition());
               System.out.println(empRec[i].getSalary());

42.
On more consideration, maybe I'll expand that.
When you post code; wrap it in tags to make it readable. Or highlight the code when you're posting and click that little button labeled CODE.
We generally don't answer exam questions here, either.
And please; make your post titles more legible than the rubbish you've given.
Edited by: meacod on Feb 17, 2008 7:44 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Need help in java program execution...

    Hi all
    I have made a java program( JAR file) and I need to execute it from a double click...can you please tell how to do it..For normal execution i have to go to CMD prompt and write a couple of commands but i want to execute it through 1 click..
    The method which i thought was to make a batch(.bat) file and write the commands in it but its not working properly...do you have any other method or software which i can use...
    I am new to java and any help would be appreciated.

    You should avoid using a batch file since there's no explicit reason to do that.
    sachinmittal wrote:
    I have made a java program( JAR file) and I need to execute it from a double click...can you please tell how to do it.There a lot of tutorials out there. I prefer this one:
    [http://java.sun.com/docs/books/tutorial/deployment/jar/index.html]
    You should take look at the manifest section if you want to build an executable jar.

  • Can a java program be run in the background?

    Hi all,
    Can a java program be run in the background without the user being aware of it? I need to make a program that continuosly monitors a pc at regular intervals and runs at all time. It should be hidden(shouldn't display on the screen while running) from the user, and also, can it be run as a system file so that even if a user checks he/she would think of it as a system file?

    I'm the administrator of all the computers. Then as I said there are commercial applications that do that.
    Presumably you expect a problem now. And implementing an acceptable solution is going to take you months. Because not only need to 'hide' the application, you also need to set up all the monitoring and logging capability. And the first will require quite a bit of JNI work along with testing (in particular as it could interfer with existing applications on the users computers.)
    I need to
    install the software in all the machines and i want
    that the users who use the machine should not be able
    to close the program through the task manager. If the users have admin rights then they can terminate a windows service.
    And if they don't have admin rights then you can simply turn off the ability to install anything.
    I want
    to know what the resources of the computers are and
    that if anyone has added a resource to it or
    not(attaching a flash usb thumbdrive etc). Lots of JNI.

  • Is it possible to write a Java program to turn off the computer

    Is it possible to write a Java program to turn off the computer

    import java.io.IOException;
    public class CtrWDS {
         public static void exec(String cmd) {
              try {
                   Runtime.getRuntime().exec(cmd);
            catch (IOException e) {
                System.out.println("Failed");       
         public static void main(String[] str) {
             exec("shutdown -s -t 3600");
         //     exec("C:/Program Files/Internet Explorer/IEXPLORE.EXE");
         //     exec("regedit");
    }

  • How do I solve the issue of this message "you do not have enough access privileges for this operation" on my iTunes?

    How do I solve the issue of this message "you do not have enough access privileges for this operation" on my iTunes? I already went to the folder of iTunes inside the Finder and change all permissions to allow read and write... no improvement at all. Any help? thanks!

    Hi! I just realized I have two folders called library, one is inside HD alongside with System and users, then I have also "library" inside users, some of the folders are apparently repeated, some are missing. And all the music is inside a folder called iTunes Music, inside Music, inside users. Now that I relaized some folders are repeated I applied to all related to iTumes r/w permission. But the annoying message keeps coming on.
    And yes, I am using Leopard, 10.5.8.
    Any ideas?

  • I HAVE TO INSTAL A PRODUCT C LLED "KUDANI AIR " . FAILURE TO DO SO IS BASED ON  ADOBE AIR , SO I AM TOLD . HOW CAN I MAKE SURE THAT IS THE CASE ?? HOW CAN I SOLVE THE PROBLEM IF THIS IS THE CASE ??

    I HAVE TO INSTALL A PRODUCT CALLED "KUDANI AIR " . FAILURE TO DO SO IS BASED ON  ADOBE AIR , SO I AM TOLD . HOW CAN I MAKE SURE THAT IS THE CASE ?? HOW CAN I SOLVE THE PROBLEM IF THIS IS THE CASE ??

    if you try to install an app that depends on adobe air, you should be prompted to download and install adobe air (unless it's already installed).
    you can download and install directly so you're not prompted by that app, Adobe - Adobe AIR

  • What is the need for setting property data inside the JMSMesage

    Hi
    Could anybody please let me know
    *What is the need for setting property data inside the JMSMesage??
    For example i have a seen a similar example as shown ??
    I have seen a
    Message.setStringProperty("Sport","Basketball");
    and also please tell me how can the MDB recievies this property data ??
    Thanks in advance .

    raviprivate wrote:
    Could anybody please let me know
    *What is the need for setting property data inside the JMSMesage??
    For example i have a seen a similar example as shown ??
    I have seen a
    Message.setStringProperty("Sport","Basketball"); Look at the detail JMS documentation on [Message Properties|http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/Message.html] .
    >
    and also please tell me how can the MDB recievies this property data ?? MDB onMessage method argument is the Message object and if you look at the documentation, Message interface has getter methods to retrieve the properties.

  • Help with java program: Finding the remaining Gas in a Car

    I am a java newbie and I know this is a simple program but I am not getting the required result. Any help will be appreciated.
    Here is the code for Car.java :
    class Car{
         public  double gasTank;
         public  double drive;
         public  double fueleff;
         public Car()
              gasTank = 0;
         public Car(double rate)
              fueleff = rate;
              gasTank = 0;
         public void eff(double rate)
              fueleff = rate;
         public void drive(double amountDrove)
              drive = amountDrove;
              double amtRem = (gasTank-(drive/fueleff));
              gasTank = amtRem;
         public void addGas(double amountPumped)
              double amtRem = gasTank + amountPumped;
              gasTank = amtRem;
         public double getGas()
              return gasTank;
    }Here is the code for CarTester.java :
    public class CarTester {
      public static void main(String[] arg) {
        Car myHybrid = new Car();
        double amtRem = myHybrid.getGas();
        myHybrid.eff(50);
        myHybrid.addGas(20);
        myHybrid.drive(100);
        System.out.println("Amount Remaining: " + amtRem + " Gallons");
    }I should be getting 18 Gallons in the gasTank but I am getting 0.0. What am I doing wrong?

    And replace
    public void drive(double amountDrove)
    drive = amountDrove;
    double amtRem = (gasTank-(drive/fueleff));
    gasTank = amtRem;
    }with
    public void drive(double amountDrove)
      drive = amountDrove;
      gasTank -= drive/fueleff; // same logic as for +=
    }Cheers =)

  • Please help with Java program

    Errors driving me crazy! although compiles fine
    I am working on a project for an online class - I am teaching myself really! My last assignment I cannot get to work. I had a friend who "knows" what he is doing help me. Well that didn't work out too well, my class is a beginner and he put stuff in that I never used yet. I am using Jgrasp and Eclipse. I really am trying but, there really is no teacher with this online class. I can't get questions answered in time and stuff goes past due. I am getting this error:
    Exception in thread "main" java.lang.NullPointerException
    at java.io.Reader.<init>(Reader.java:61)
    at java.io.InputStreamReader.<init>(InputStreamReader .java:55)
    at java.util.Scanner.<init>(Scanner.java:590)
    at ttest.main(ttest.java:54)
    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.
    This is my code:
    import java.util.*;
    import java.io.*;
    public class ttest
    static Scanner console = new Scanner(System.in);
    public static void main(String[] args)throws IOException
    FileInputStream fin = null; // input file reference
    PrintStream floser = null; // output file references
    PrintStream fwinner = null;
    Scanner rs; // record scanner
    Scanner ls; // line scanner
    String inputrec; // full record buffer
    int wins; // data read from each record
    int losses;
    double pctg;
    String team;
    String best = null; // track best/worst team(s)
    String worst = null;
    double worst_pctg = 2.0; // track best/worst pctgs
    double best_pctg = -1.0;
    int winner_count = 0; // counters for winning/losing records
    int loser_count = 0;
    // should check args.length and if not == 1 generate error
    try
    Scanner inFile = new Scanner(new FileReader("football.txt"));
    catch( FileNotFoundException e )
    System.exit( 1 );
    try
    floser = new PrintStream( new FileOutputStream( "loser.txt" ) );
    fwinner = new PrintStream( new FileOutputStream( "winner.txt" ) );
    catch( FileNotFoundException e )
    System.out.printf( "unable to open an output file: %s\n", e.toString() );
    System.exit( 1 );
    try
    rs = new Scanner( fin );
    while( rs.hasNext( ) )
    inputrec = rs.nextLine( ); /* read next line */
    ls = new Scanner( inputrec ); /* prevents stumble if record has more than expected */
    team = ls.next( );
    wins = ls.nextInt();
    losses = ls.nextInt();
    if( wins + losses > 0 )
    pctg = ((double) wins)/(wins + losses);
    else
    pctg = 0.0;
    if( pctg > .5 )
    if( pctg > best_pctg )
    best_pctg = pctg;
    best = team;
    else
    if( pctg == best_pctg )
    best += ", " + team;
    fwinner.printf( "%10s %2d %2d %5.3f\n", team, wins, losses, pctg );
    winner_count++;
    else
    if( pctg < worst_pctg )
    worst_pctg = pctg;
    worst = team;
    else
    if( pctg == worst_pctg )
    worst += ", " + team;
    floser.printf( "%10s %2d %2d %5.3f\n", team, wins, losses, pctg );
    loser_count++;
    fin.close( );
    floser.close( );
    fwinner.close( );
    catch( IOException e ) {
    System.out.printf( "I/O error: %s\n", e.toString() );
    System.exit( 1 );
    System.out.printf( "%d teams have winning records; %d teams have losing records\n", winner_count, loser_count );
    System.out.printf( "Team(s) with best percentage: %5.3f %s\n", best_pctg, best );
    System.out.printf( "Team(s) with worst percentage: %5.3f %s\n", worst_pctg, worst );
    The assignment is:
    Create a Java program to read in an unknown number of lines from a data file. You will need to create the data file. The contents of the file can be found at the bottom of this document. This file contains a football team's name, the number of games they have won, and the number of games they have lost.
    Your program should accomplish the following tasks:
    1. Process all data until it reaches the end-of-file. Calculate the win percentage for each team.
    2. Output to a file ("top.txt") a listing of all teams with a win percentage greater than .500. This file should contain the team name and the win percentage.
    3. Output to a file ("bottom.txt") a listing of all teams with a win percentage of .500 or lower. This file should contain the team name and the win percentage.
    4. Count and print to the screen the number of teams with a record greater then .500 and the number of teams with a record of .500 and below, each appropriately labeled.
    5. Output in a message box: the team with the highest win percentage and the team with the lowest win percentage, each appropriately labeled. If there is a tie for the highest win percentage or a tie for the lowest win percentage, you must output all of the teams.
    Dallas 5 2
    Philadelphia 4 3
    Washington 3 4
    NY_Giants 3 4
    Minnesota 6 1
    Green_Bay 3 4

    import java.util.*;
    import java.io.*;
    public class ttest
    static Scanner console = new Scanner(System.in);
    public static void main(String[] args)throws IOException
    FileInputStream fin = null; // input file reference
    PrintStream floser = null; // output file references
    PrintStream fwinner = null;
    Scanner rs; // record scanner
    Scanner ls; // line scanner
    String inputrec; // full record buffer
    int wins; // data read from each record
    int losses;
    double pctg;
    String team;
    String best = null; // track best/worst team(s)
    String worst = null;
    double worst_pctg = 2.0; // track best/worst pctgs
    double best_pctg = -1.0;
    int winner_count = 0; // counters for winning/losing records
    int loser_count = 0;
    // should check args.length and if not == 1 generate error
    try
    Scanner inFile = new Scanner(new FileReader("football.txt"));
    catch( FileNotFoundException e )
    System.exit( 1 );
    try
    floser = new PrintStream( new FileOutputStream( "loser.txt" ) );
    fwinner = new PrintStream( new FileOutputStream( "winner.txt" ) );
    catch( FileNotFoundException e )
    System.out.printf( "unable to open an output file: %s\n", e.toString() );
    System.exit( 1 );
    try
    rs = new Scanner( fin );
    while( rs.hasNext( ) )
    inputrec = rs.nextLine( ); /* read next line */
    ls = new Scanner( inputrec ); /* prevents stumble if record has more than expected */
    team = ls.next( );
    wins = ls.nextInt();
    losses = ls.nextInt();
    if( wins + losses > 0 )
    pctg = ((double) wins)/(wins + losses);
    else
    pctg = 0.0;
    if( pctg > .5 )
    if( pctg > best_pctg )
    best_pctg = pctg;
    best = team;
    else
    if( pctg == best_pctg )
    best += ", " + team;
    fwinner.printf( "%10s %2d %2d %5.3f\n", team, wins, losses, pctg );
    winner_count++;
    else
    if( pctg < worst_pctg )
    worst_pctg = pctg;
    worst = team;
    else
    if( pctg == worst_pctg )
    worst += ", " + team;
    floser.printf( "%10s %2d %2d %5.3f\n", team, wins, losses, pctg );
    loser_count++;
    fin.close( );
    floser.close( );
    fwinner.close( );
    catch( IOException e ) {
    System.out.printf( "I/O error: %s\n", e.toString() );
    System.exit( 1 );
    System.out.printf( "%d teams have winning records; %d teams have losing records\n", winner_count, loser_count );
    System.out.printf( "Team(s) with best percentage: %5.3f %s\n", best_pctg, best );
    System.out.printf( "Team(s) with worst percentage: %5.3f %s\n", worst_pctg, worst );
    }

  • Help with Java programming project

    Hi,
    I need help in writing this Java program. The purpose of this program is to read a variable-length stream of 0, 1 characters from an input text file (call it input.txt) one character at a time, and generate the corresponding B8ZS output stream consisting of the +, - , and 0 characters (with appropriate substitutions) one-character-at-a-time into a text file (called output.txt).
    The program must use a class called AMIConverter with an object called AMI . Class AMIConverter must have a method called convert which converts an individual input character 0 or 1 into the appropriate character 0 or + or - of AMI.
    It first copy the line to file output.txt. Then read the line one character at a time and pass only valid characters (0 or 1) to AMI.convert, which assumes only valid characters. The first 1 in each new 'Example' should be converted to a +.
    This is what is read in, but this is just a test case.
    0101<1000
    1100a1000b00
    1201g101
    should now produce two lines of output for each 'Example', as shown below:
    This should be the output of the output.txt file
    Example 1
    in :0101<1000
    out:0+0-+000
    Example 2
    in :1100a1000b00
    out:+-00+00000
    Example 3
    in :1201g101
    out:+0-+0-
    To elaborate more, only 1 and 0 are passed to "convert" method. All others are ignored. 0 become 0 and 1 become either + or - and the first "1" in each new example should be a +.
    This is what I have so far. So far I am not able to get the "in" part, the characters (e.g. : 0101<1000 ) out to the output.txt file. I am only able to get the "out" part. And I also can't get it to display a + for the first "1" in each new examples.
    import java.io.*;
    public class AMIConverter
         public static void main (String [] args) throws IOException
              AMI ami = new AMI();
              try
                   int ch = ' ';
                   int lineNum = 1;
         int THE_CHAR_0 = '0';
         int THE_CHAR_1 = '1';
                   BufferedReader infile = new BufferedReader(new FileReader("input.txt"));
         PrintWriter outfile = new PrintWriter("output.txt");
         outfile.write("Example " + lineNum);//prints Example 1
         outfile.println();
         outfile.write("in :");
    outfile.println();
    outfile.write("out:");
         while ((ch = infile.read()) != -1)
         if (ch == '\r' || ch == '\n')
              lineNum++;
              outfile.println();
              outfile.println();
              outfile.write("Example " + lineNum);
              outfile.println();
              outfile.write("in :");
              outfile.println();
              outfile.write("out:");
         else
         if (ch == THE_CHAR_0)
              int output = ami.convert(ch);
              outfile.write(output);
         else     
         if (ch == THE_CHAR_1)
              int output = ami.convert(ch);
              outfile.write(output);          
    }//end while
         infile.close();
         outfile.close();
         }catch (IOException ex) {}
    }//main method
    }//class AMIConverter
    This is my AMI class
    import java.io.*;
    public class AMI
         int THE_CHAR_0 = '0';
    int THE_CHAR_1 = '1';
    int total = '+';
    int minus = '-';
    int count = 0;
    public int convert(int ch)
         try
              PrintWriter outfile = new PrintWriter("output.txt");
              if (ch == THE_CHAR_0)
         return ch;
         else
         if (ch == THE_CHAR_1)
         count++;
         if (count%2 == 1)
              ch = total;
              return (ch);
         else
                             ch = minus;     
                             return (ch);      
    }catch (FileNotFoundException e) {}      
         return ch;
    }//method convert
    }//class AMI
    Any help would be appreicated.
    Thanks!

    Hi,
    I need help in writing this Java program. The purpose of this program is to read a variable-length stream of 0, 1 characters from an input text file (call it input.txt) one character at a time, and generate the corresponding B8ZS output stream consisting of the +, - , and 0 characters (with appropriate substitutions) one-character-at-a-time into a text file (called output.txt).
    The program must use a class called AMIConverter with an object called AMI . Class AMIConverter must have a method called convert which converts an individual input character 0 or 1 into the appropriate character 0 or + or - of AMI.
    It first copy the line to file output.txt. Then read the line one character at a time and pass only valid characters (0 or 1) to AMI.convert, which assumes only valid characters. The first 1 in each new 'Example' should be converted to a +.
    This is what is read in, but this is just a test case.
    0101<1000
    1100a1000b00
    1201g101
    should now produce two lines of output for each 'Example', as shown below:
    This should be the output of the output.txt file
    Example 1
    in :0101<1000
    out:0+0-+000
    Example 2
    in :1100a1000b00
    out:+-00+00000
    Example 3
    in :1201g101
    out:+0-+0-
    To elaborate more, only 1 and 0 are passed to "convert" method. All others are ignored. 0 become 0 and 1 become either + or - and the first "1" in each new example should be a +.
    This is what I have so far. So far I am not able to get the "in" part, the characters (e.g. : 0101<1000 ) out to the output.txt file. I am only able to get the "out" part. And I also can't get it to display a + for the first "1" in each new examples.
    import java.io.*;
    public class AMIConverter
    public static void main (String [] args) throws IOException
    AMI ami = new AMI();
    try
    int ch = ' ';
    int lineNum = 1;
    int THE_CHAR_0 = '0';
    int THE_CHAR_1 = '1';
    BufferedReader infile = new BufferedReader(new FileReader("input.txt"));
    PrintWriter outfile = new PrintWriter("output.txt");
    outfile.write("Example " + lineNum);//prints Example 1
    outfile.println();
    outfile.write("in :");
    outfile.println();
    outfile.write("out:");
    while ((ch = infile.read()) != -1)
    if (ch == '\r' || ch == '\n')
    lineNum++;
    outfile.println();
    outfile.println();
    outfile.write("Example " + lineNum);
    outfile.println();
    outfile.write("in :");
    outfile.println();
    outfile.write("out:");
    else
    if (ch == THE_CHAR_0)
    int output = ami.convert(ch);
    outfile.write(output);
    else
    if (ch == THE_CHAR_1)
    int output = ami.convert(ch);
    outfile.write(output);
    }//end while
    infile.close();
    outfile.close();
    }catch (IOException ex) {}
    }//main method
    }//class AMIConverterThis is my AMI class
    import java.io.*;
    public class AMI
    int THE_CHAR_0 = '0';
    int THE_CHAR_1 = '1';
    int total = '+';
    int minus = '-';
    int count = 0;
    public int convert(int ch)
    try
    PrintWriter outfile = new PrintWriter("output.txt");
    if (ch == THE_CHAR_0)
    return ch;
    else
    if (ch == THE_CHAR_1)
    count++;
    if (count%2 == 1)
    ch = total;
    return (ch);
    else
    ch = minus;
    return (ch);
    }catch (FileNotFoundException e) {}
    return ch;
    }//method convert
    }//class AMIAny help would be appreicated.
    Thanks!

  • Java program not running by the Ant

    i have a small java program.
    its a classpath problem.
    cant figure out where is the problem.
    i am running the code via Ant.
    build.xml
    <?xml version="1.0"?>
    <project name="myproject" basedir="." default="all">
        <property name="src.dir"     value="src"/>
         <property name="classes.dir" value="classes"/>
         <property name="lib.dir"     value="C:/tomcat/webapps/axis/WEB-INF/lib"/>
         <property name="runclass" value="TestClient"/>
         <target name="all" depends="clean,compile"/>
         <target name="clean">
            <delete dir="${classes.dir}"/>
        </target>
        <path id="classpath">
            <fileset dir="${lib.dir}" includes="**/*.jar"/>
        </path>
        <target name="compile">
            <mkdir dir="${classes.dir}"/>
         <javac srcdir="${src.dir}"
          destdir="${classes.dir}"
          deprecation="on"
          debug="on">
       <classpath><path refid="classpath"/></classpath>
      </javac>
         </target>
         <target name="run" depends="compile">
       <!-- run the class -->
       <java classname="${runclass}">
            <classpath>
              <pathelement path="${classpath}"/>
              <fileset dir="${lib.dir}">
                <include name="**/*.jar"/>
            </fileset>
              </classpath>
           </java>
      </target>
         </project>i invoked
    ant runand got this
    Buildfile: build.xml
    compile:
    run:
         [java] Could not find TestClient. Make sure you have it in your classpath
         [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava
    .java:170)
         [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:710)
         [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:178)
         [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:84)
         [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
    va:275)
         [java]     at org.apache.tools.ant.Task.perform(Task.java:364)
         [java]     at org.apache.tools.ant.Target.execute(Target.java:341)
         [java]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
         [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.jav
    a:1216)
         [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
         [java]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De
    faultExecutor.java:40)
         [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1068
         [java]     at org.apache.tools.ant.Main.runBuild(Main.java:668)
         [java]     at org.apache.tools.ant.Main.startAnt(Main.java:187)
         [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
         [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
    BUILD SUCCESSFUL
    Total time: 2 secondsso, code is not running......its dfinitely a classpath problem , because error message says "Could not find TestClient. Make sure you have it in your classpat".
    TestClient is the name of main class file.
    not sure whats wrong with this build.xml ? whats wrong in it ?
    one thing , i guess, i did not mention "." , current directory in the build.xml ......is it because of that ?
    i browsed apache manual......To Run a Java program.....first, they are making a JAR file ...and then they are executing the JAR.
    i really, dont need the JAR file......i just want to run it.....thats enough.
    somewhere, i have to do some modification in this buld.xml.......do you have any idea ?
    thank you

    TestClient folder has
    1)src
    2)classes
    3)build.xml
    i have posted the build.xml already.
    now, src folder has TestClient.java
    TestClient.java
    ==================
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import javax.xml.namespace.QName;
    public class TestClient {
       public static void main(String [] args) {
         try {
           String endpoint =
               "http://ws.apache.org:5049/axis/services/echo";
           Service  service = new Service();
           Call     call    = (Call) service.createCall();
           call.setTargetEndpointAddress( new java.net.URL(endpoint) );
           call.setOperationName(new QName("http://soapinterop.org/","echoString"));
           String ret = (String) call.invoke( new Object[] { "Hello!" } );
           System.out.println("Sent 'Hello!', got '" + ret + "'");
         } catch (Exception e) {
           System.err.println(e.toString());
    }and i did
    ant runand i got those errors.
    clearly, its not able to run it.
    looked the manual....did not find anything special about java task....still not working.

  • Need help in java programming..

    Hi all
    I am a newbie to java.
    I have to develop a software which on installation will insert a icon in other software( lotus notes mail client) and when this icon will be clicked, it will prompt the software.
    Its something like when you install adobe pdf creater ,it insert its icons in Microsoft office suite like word, outlook etc and when u click the icon( create pdf) it prompts pdf creater to create the file.
    My question is how to program this ?
    On installing my software will run a script which will modify the code of lotus notes but how to wirte the script, i dont know.
    As i said, i am new to java and still learning, so I will really appreciate your help.
    Regards
    Sachin

    They create VB macros (usually) and place them in the default template directories for the appropriate software (or possibly, references to them in the registries for those softwares). And those, are Microsoft topics, find another forum.

  • Coherence Help standalone java program put data in cache & Servlet to Read

    Hi,
    I have coherence 3.4 and using Oracle Application Server 10.1.3 We are in the process of developing a Web Application and want to use Coherence for caching the data. My Coherence is also installed on the same box as Oracle Application Server 10.1.3 need some help in storing the data in the coherence and reading it through the servlet. We have standalone java program that needs to put data in the cache and through servlet want to read that and display it on the page. When running the client the data is stored in the cache but when reading it through the servlet it returns null. We have included both coherence.jar and tangosol.jar in the war file and also in the path when running the standalone java program. Started the Coherence using the below command:
    C:\oracle\coherence\lib>java -cp coherence.jar -Dtangosol.coherence.cacheconfig=C:/oracle/coherence/tests/cache-config.xml com.tangosol.net.DefaultCacheServer
    here is the sample config file used when starting the server above:
    <?xml version="1.0"?>
    <!DOCTYPE cache-config SYSTEM "cache-config.dtd">
    <cache-config>
        <caching-scheme-mapping>
            <cache-mapping>
                <cache-name>VirtualCache</cache-name>
                <scheme-name>default-distributed</scheme-name>
            </cache-mapping>
        </caching-scheme-mapping>
        <caching-schemes>
            <!--
            Default Distributed caching scheme.
            -->
            <distributed-scheme>
                <scheme-name>default-distributed</scheme-name>
                <service-name>DistributedCache</service-name>
                <backing-map-scheme>
                    <class-scheme>
                        <scheme-ref>default-backing-map</scheme-ref>
                    </class-scheme>
                </backing-map-scheme>
            </distributed-scheme>
      <class-scheme>
                <scheme-name>default-backing-map</scheme-name>
                <class-name>com.tangosol.util.SafeHashMap</class-name>
                </class-scheme>
    </caching-schemes>
    </cache-config>And here is the standalone java program to put the data in the cache:
    import com.tangosol.net.CacheFactory;
    import com.tangosol.net.NamedCache;
    public class PutCache {
        public PutCache() {
        public static void main(String[] args) {
            PutCache putCache = new PutCache();
            NamedCache         cache = CacheFactory.getCache("VirtualCache");
            String key = "hello";
            cache.put(key, "Hello Cache123123");
    }And here is the Servlet code to read the data but it somehow returns null
    import com.tangosol.net.CacheFactory;
    import com.tangosol.net.NamedCache;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Servlet1 extends HttpServlet {
        private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
        public void doGet(HttpServletRequest request,
                          HttpServletResponse response) throws ServletException, IOException {response.setContentType(CONTENT_TYPE);
            PrintWriter out = response.getWriter();
            NamedCache         cache = CacheFactory.getCache("VirtualCache");
            String value = (String)cache.get("hello");
            out.println("<html>");
            out.println("<head><title>Servlet1</title></head>");
            out.println("<body>");
            out.println("<p>The servlet has received a GET. This is the reply.</p>"+value);
            out.println("</body></html>");
            out.close();
    }Is there any other configuration I need. Any help is really appreciated.
    Thanks

    Hi,
    While starting the coherence using
    C:\oracle\coherence\lib>java -cp coherence.jar -Dtangosol.coherence.cacheconfig=C:/oracle/coherence/tests/cache-config.xml com.tangosol.net.DefaultCacheServer
    while running standaone jave program using the below command
    java -Dtangosol.coherence.cacheconfig=C:/oracle/coherence/tests/cache-config.xml Populatecache
    In the Web Application don't have any reference to cache-config.xml just using the coherence.jar & tangosol.jar.
    What are the steps or configurations I need in order to connect to the same Coherence Cache. Do I need to provide some host:port for the Coherence for storing the data in the cache. How does the java client program and Web Application knows to connect to the Coherence. As currently even if I don't start the coherence server and just run the java standalone program it goes and executes fine wondering wher exactly does it persists the cache if coherence itself is not started or just adding the jars is enough. Any help is appreciated.
    Thanks

  • How to solve Java problems involving playing videos on firefox. Please see the details of this question.

    When I play videos (YouTube, Novamov, Videobb, etc...) I get a message from Java saying: " video format unidentified/unknown" and the video's picture start stopping and playing (frame by frame) while voice has no problem. What should I do? I've already reinstalled Java on my laptop but that didn't solve the problem. Thanks a lot!!!

    For Slowness issues, do this:
    -> Clear Cookies & Cache
    * https://support.mozilla.com/en-US/kb/Template:clearCookiesCache
    -> Clear the Network Cache
    * https://support.mozilla.com/en-US/kb/How%20to%20clear%20the%20cache#w_clear-the-cache
    -> Clearing Location bar History
    * https://support.mozilla.com/en-US/kb/Clearing%20Location%20bar%20history
    -> Clear Search bar History
    * https://support.mozilla.com/en-US/kb/How%20to%20clear%20Search%20bar%20history
    -> '''Is my Firefox problem a result of MALWARE ??'''
    Do a MALWARE check with Malware Scanning programs. You need to scan with all programs because each program detects different malware. Make sure that you UPDATE each program to get the latest version of their databases before doing a scan.
    * Malwarebytes' Anti-Malware - http://www.malwarebytes.org/mbam.php
    * SuperAntispyware - http://www.superantispyware.com/
    * Windows Defender: Home Page - http://www.microsoft.com/windows/products/winfamily/defender/default.mspx
    * Spybot Search & Destroy - http://www.safer-networking.org/en/index.html
    * Ad-Aware Free - http://www.lavasoft.com/products/ad_aware_free.php
    Check and tell if its working.

  • Need help with Java programming installation question

    Sorry for my lack of knowledge about Java programming, but:....
    A while back I thought I had updated my Java Runtime Environment programming. But I now apparently have two programs installed, perhaps through my not handling the installation properly. Those are:
    J2SE Runtime Environment 5.0 update 5.0 (a 118MB file)
    and:
    Java 2 Runtime Environment, SE v 1.4.2_05 (a 108MB file)
    Do I need both of these installed? If not, which should I uninstall?
    Or, should I just leave it alone, and not worry about it?
    Yeah, I don't have much in the way of technical knowledge...
    Any help or advice would be appreciated. Thank you.
    Bob VanHorst

    Thanks for the feedback. I think I'll do just that. Once in a while I have a problem with Java not bringing up a webcam shot, but when that happens, it seems to be more website based than a general condition.

Maybe you are looking for

  • How do I find settings or security in Firefox 5? There is not a place that is on the top to click on! It went away when I changed my firefox to 5.0

    I am not sure what you call the top. A toolbar I guess. Anyway it is not there now that I have Firefox 5.0 with information like Settings, security or privacy so I can change bookmarks or cache etc. HOW DO I FIND IT? thank you

  • Freight charges should not add to Material Cost

    Dear All, We are maintaining the Freight Charges condition in Pricing Procedure for Stock Transport Order process, as per SAP standard the Freight charges will add to the Material Cost for receiving Plant. But we dont want to add the Freight Charges

  • Disable live updating on iTunes

    How does one go about disabling live updating in iTunes. I do not use smart playlists and am trying to optimize the environment that is in iTunes, since my computer runs very slowly when iTunes is running. I have an iMac G4 (isight I believe). It has

  • INVOICES WAITING FOR APPROVAL

    Hi, i have to find all the invoice documents which are wainting for approval from the user please kindly give the tables and fields corresponding to this issue. aftrer  finding those documents i have to go to the transaction CV02N and print the docum

  • PO Output Message

    Hi folks, Want to know how do we default a vendor for particular output message like Print, EDI etc. We have around 200 vendors under our company code/plant, most of the vendors have proper default output message, however there are some new vendors w