I need help instantly on this program please

import java.util.*;
public class D3
          private static int[] z = new int[100000];
private static int first=z[0];
          private static int last=z[n-1];
          private static int n=100000;
public static void main(String args[])
Scanner input=new Scanner(System.in);
for(int i=0;i<z.length;i++)
          z=2*i;
int seqSearch(z;50000;n); //method call 4 key where key=mid
          int binSearch(z;first;last;50000);
          int seqSearch(z;35467;n); //method call 4 key where key in the left half
          int binSearch(z;first;last;35467);
          int seqSearch(z;89703;n); //method call 4 key where key in the right half
          int binSearch(z;first;last;89703);
          public int seqSearch(int z[];int key;int n)
     long start = System.currentTimeMillis();
int count=0;
int ans=-1;
for(int i=0;i<n;i++)
if z[i]=key
count++
{ans=i
break;}
return ans;
long elapsed = System.currentTimeMillis() - start;
System.out.print("Execution Time:" + elapsed);
System.out.print("# of Basic Operations:" + count);
     public int binSearch(int z[];int first;int last;int key)
     long start = System.currentTimeMillis();
     int count=0;
     if(last<first){
     count++;
     index=-1;
     else
     count++;
     int mid=(first+last)/2
     if(ket=z[mid]{
     index=mid;
     else
     if(key<z[mid]){
     index = binSearch(z[];first;mid-1;key);
     else
     index=binSearch(z[];mid+1;last;key);
     return index;
     long elapsed = System.currentTimeMillis() - start;
     System.out.print("Execution Time:" + elapsed);
     System.out.print("# of Basic Operations:" + count);
// if anyone could tell me whats wrong with my code i'd be greatful...the program is supposed to perform binary and sequential search on a sorted array of 100000 numbers.once on an item in the middle of the array once on the right side of it and once on the left side...i also need to count the number of basic operations for the same number in both sequential and binary to see whats better.and i need to check the time...plz i need help now,,,

"Guide to a first-time poster"
you need to add exclamation marks to signify how urgent it is
e.g.
i need help instantly on this program please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
capital letters is better
I NEED HELP INSTANTLY ON THIS PROGRAM PLEASE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
starting the italics on line 1, better again
import java.util.*;
public class D3
private static int[] z = new int[100000];
private static int first=z[0];
private static int last=z[n-1];
private static int n=100000;
public static void main(String args[])
Scanner input=new Scanner(System.in);
for(int i=0;i<z.length;i++)
z=2*i;
int seqSearch(z;50000;n); //method call 4 key where key=mid
int binSearch(z;first;last;50000);
int seqSearch(z;35467;n); //method call 4 key where key in the left half
int binSearch(z;first;last;35467);
int seqSearch(z;89703;n); //method call 4 key where key in the right half
int binSearch(z;first;last;89703);
public int seqSearch(int z[];int key;int n)
long start = System.currentTimeMillis();
int count=0;
int ans=-1;
for(int i=0;i<n;i++)
if z=key
count++
{ans=i
break;}
return ans;
long elapsed = System.currentTimeMillis() - start;
System.out.print("Execution Time:" + elapsed);
System.out.print("# of Basic Operations:" + count);
public int binSearch(int z[];int first;int last;int key)
long start = System.currentTimeMillis();
int count=0;
if(last><first){
count++;
index=-1;
else
count++;
int mid=(first+last)/2
if(ket=z[mid]{
index=mid;
else
if(key><z[mid]){
index = binSearch(z[];first;mid-1;key);
else
index=binSearch(z[];mid+1;last;key);
return index;
long elapsed = System.currentTimeMillis() - start;
System.out.print("Execution Time:" + elapsed);
System.out.print("# of Basic Operations:" + count);
and what about the dukes, offer 10 (never to be awarded, of course)
do this, then sit back and watch the replies roll in.

Similar Messages

  • I Need Help With Making This Program Work

    The directions for this program:
    Enhance the Student class to contain an Advisor. The advisor has a name (type Name), phone number (type String). Place edits in the Name class to validate that the length of the first name is between 1 and 15, middle inital <= 1, and lastName is between 1 and 15. Throw an IllegalArgumentException if the edits are not met. The advisor attribute in the Student class should replace the advisorName. Document the Name, Advisor, and Student classes including the preconditions and postconditions where necessary. Create a test class that will instantiate a Student, fully populate all of its fields and print it out. Do not document the test class. Submit for grade Student.java, Advisor.java, and Name.java.
    public class Student
         private Advisor advisorName;
         private Advisor phoneNumber;
         public void setAdvisorName(Advisor anAdvisorName)
             advisorName = anAdvisorName;
         public Advisor getAdvisorName()
             return advisorName;
         public void setPhoneNumber(Advisor aPhoneNumber)
             phoneNumber = aPhoneNumber;
         public Advisor getPhoneNumber()
             return phoneNumber;
    public class Name
         private String firstName;
         private String midInit;
         private String lastName;
         public String getFullName()
             return firstName + " " + midInit + " " + lastName;
         public String getFirstName()
             return firstName;
         public String getMidInit()
             return midInit;
         public String getLastName()
             return lastName;
            Calculates length of the first name.
            (Postcondition: getFirstName() >= 0)
            @param s the length of the first name to calculate
            (Precondition: length of aFirstName > 0 and <= 15)
         public void setFirstName(String aFirstName)
             if(aFirstName.length() < 1)
               throw new IllegalArgumentException();
             if(aFirstName.length() > 15)
               throw new IllegalArgumentException();
               firstName = aFirstName;
            Calculates length of the middle initial.
            (Postcondition: getMidInit() >= 0)
            @param s the length of the middle initial to calculate
            (Precondition: length of s > 0 and <= 1)
         public void setMidInit(String aMidInit)
             if(aMidInit.length() == 1)
               throw new IllegalArgumentException();
               midInit = aMidInit;
            Calculates length of the last name.
            (Postcondition: getLastName() >= 0)
            @param s the length of the last name to calculate
            (Precondition: length of aLastName > 0 and <= 15)
         public void setLastName(String aLastName)
             if(aLastName.length() < 1)
               throw new IllegalArgumentException();
             if(aLastName.length() > 15)
               throw new IllegalArgumentException();    
               lastName = aLastName;
    public class Advisor
         private Name advisorName;
         private String phoneNumber;
         public String getFullName()
            return advisorName + " " + phoneNumber + " ";
         public Name getAdvisorName()
             return advisorName;
         public String getPhoneNumber()
             return phoneNumber;
         public void setAdvisorName(Name anAdvisorName)
             advisorName = anAdvisorName;
         public void setPhoneNumber(String aPhoneNumber)
             phoneNumber = aPhoneNumber;
    public class Test
         public static void main(String[] args)
            Name name1 = new Name();
            name1.setFirstName("Timothy");
            name1.setLastName("O'Neal");
            name1.setMidInit("J.");
            System.out.println("name1 = " +
                name1.getFirstName() + " " +
                name1.getMidInit() + " " +
                name1.getLastName());
            Student st = new Student();
            st.setAdvisorName(name1);
            Name name2 = st.getAdvisorName();
            System.out.println("name2 = " +
                name2.getFirstName() + " " +
                name2.getMidInit() + " " +
                name2.getLastName());   
            name2.setFirstName("Timothy");
            System.out.println("name2 = " +
                name2.getFirstName() + " " +
                name2.getMidInit() + " " +
                name2.getLastName());       
            System.out.println("name1 = " +
                name1.getFirstName() + " " +
                name1.getMidInit() + " " +
                name1.getLastName());
            System.out.println("name1 = " + name1.getFullName());   
            System.out.println("name2 = " + name2.getFullName());
    }I can't get the test class to compile and i'm not sure if this is what i'm suppose to do

    public class Test
    public static void main(String[] args)
    Student st = new Student();
    Advisor advisor = new Advisor();
    st.setAdvisor(advisor);
    Name name1 = new Name();
    name1.setFirstName("Jake");
    name1.setLastName("Schmidt");
    name1.setMidInit("K.");You have the general idea, I think. You are just doing it backwards.
    You create and advisor and assign it to a student. But you don't give
    the advisor a name until after you assign it to the student.
    You should create an advisor, give the advisor a name and then add it to the student.
    //create the name
    Name name1 = new Name();
    name1.setFirstName("John");
    name1.setLastName("Smith");
    name1.setMidInit("K.");
    //create the advisor
    Advisor advisor = new Advisor();
    advisor.setAdvisorName(name1);
    //create the student
    Student student = new Student();
    //assign the advisor to the student
    student.setAdvisor(advisor);
    //now the student has an advisor named John K. Smith
    //What is the name of the advisor?
    String name = st.advisor.getAdvisorName().getFullName();
    //I know that line looks complicated...but that's how you have created your class structure.
    Instead you could have done:
    Class Student{
    private Advisor advisor;
    public String getAdvisorName(){
    return advisor.getFullName();
    class Advisor{
    private Name advisorName;
    public getFullName(){
    return advisorName.getFullName();
    This way, if you wanted to know the advisor's name you would go:
    String name = st.getAdvisorName();
    which is much easier.
    I think it would be much easier to help you if we were both in the same room, on the same computer :)

  • PLEASE   CAN SOMEOME HELP ME INSTALL THIS PROGRAM????

    PLease  can someone help me install this program??  I am not computer literate.

    What program specifically are you struggling with? What operating system are you using? What happens when you try?

  • Need help for writing extract program

    hi
    i need help for writing extract program to retriew data from legacy system.
    i already developed bdc programs for me31k and me21.
    my requirement is to write extract program s for those t.codes.
    to retriew data from legacy system and stored in flat file.

    i need help with a java program. it is a program that allows the user to enter a student's GPA, number of extracurricular activities, and number of service activities. The user can not enter a gpa above 4.0 or below 0. The user can not enter a negative number for the number of both activities. If the student meets the following criteria: 1) GPA of 3.8 or above and at least one extracurricular activity and one service activity, 2) GPA below 3.8 but at least 3.4 and a total of at least three extracurricular and service activities, 3) GPA below 3.4 but at least 3.0 and at least two extracurricular activities and three service activities, the message "Scholarship candidate" should display. If the student does not meet the criteria above, then the message"not a candidate" should display. Can you help me, please?
    You haven't posted ANY 'java program' for us to help with.
    The forum is NOT a coding service. It is to help you with YOUR code.
    Post the code you have written and SHOW us (don't just tell us) how you compile it and execute it and the results you get. Then we can help you with any problems you are are having.
    If you need help understanding just what the program should be doing you need to ask your instructor to clarify the assignment.

  • TS3694 hello i am trying to update my phone . i am connecting it to itunes but it is giving error 3194 . can you help me resolve this problem please.

    hello i am trying to update my phone . i am connecting it to itunes but it is giving error 3194 . can you help me resolve this problem please.

    Hi ali hakim,
    Welcome to the Support Communities!
    The article below may be able to help you with this issue.
    Click on the link to see more details and screenshots.
    iOS: Restore error 3194 or 'This device isn't eligible for the requested build'
    http://support.apple.com/kb/TS4451
    This occurs when iTunes is unable to communicate with the update-and-restore server (gs.apple.com). This is most likely because it is being blocked, redirected, or interrupted by security software, hosts-file entries, or other third-party software.
    Cheers,
    - Judy

  • My old iMac and OS 10.4 will not accept the New iTunes Version 10 application and I can't get past the screen offering to download iTunes 10.  This is wrong and I need help getting past this situation. Help!

    My old iMac and OS 10.4 will not accept the New iTunes Version 10 application and I can't get past the screen offering to download iTunes 10.  This is wrong and I need help getting past this situation. Help!

    Sure, you can get around it if you don't need the newest version of iTunes. I still use version 7.5 because the newer versions didn't strike me as offering anything I needed.
    If you do need a version 10-something then you will have to upgrade your operating system to Leopard (fi your computer will support it) at least.  If you need 10.5 for some reason then there's no getting around it, you will have to buy a new computer.

  • I need help fixing kernel panic asap please help

    i need help fixing kernel panic asap please help

    OS X- About kernel panics
    Mac OS X- How to log a kernel panic
    Post a copy of your most recent complete panic log.

  • Hello, I have been exporting my photos with a watermark. Without changing any settings, half way through my day things changed, and now about 1 out of 7 photos have the watermark after export. Change you helpe me change this back please?

    Hello, I have been exporting my photos with a watermark. Without changing any settings, half way through my day things changed, and now about 1 out of 7 photos have the watermark after export. Change you help me change this back please? Has anyone had this issue before?

        I'm sorry to learn that you have endured the audio issues outlined in your post for almost 2 years SusanLM1! This is certainly not normal! Let's get to the bottom of this issue, first please confirm your phone model; your mention that you have the iPhone 5 but your post is on the iPhone 5S forum. Also, share the iOS version currently installed on your phone. What is your ZIP code? Does this happen mainly while you make/receive calls from a particular location (home, office, etc)?
    AntonioC_VZW Follow us on Twitter at www.twitter.com/VZWSupport

  • TS1424 I get "We could not complete your iTunes Store request. An unknown error occurred (4002)  Can any person help me with this on, please?

    I get "We could not complete your iTunes Store request. An unknown error occurred (4002)  Can any person help me with this on, please?

    Turning off iTunes Match and Genius and then turning them back on appears to have worked for some people e.g.
    https://discussions.apple.com/message/22059685#22059685
    https://discussions.apple.com/message/18427550#18427550

  • HT1206 I can't log into the Itunes store.  I type in my Apple ID and my password and the message "This Apple ID cannot be used for the iTunes Store." "Enter another Apple ID."  I need help on fixing this.

    I can't log into the Itunes store.  I type in my Apple ID and my password and the message "This Apple ID cannot be used for the iTunes Store." "Enter another Apple ID."  I need help on fixing this.

    Yeah I'm starting to see a ton of forums posts right now about the same thing :/ I wonder what's going on

  • I need Some help to complete this program

    i write this program to call file from my hard drive "the file name is
    input.tex" "the program the file and the result for the program are below"
    please read the program and the file befor you read my question
    now, i need to use 3 arrays
    1) first array to read this part
    include[0]: VAR ZRO 1
    include[1]: +0000000000
    include[2]: VAR I 1
    include[3]: +0000000000
    include[4]: VAR SUM 1
    include[5]: +0000000000
    include[6]: VAR AVG 1
    include[7]: +0000000000
    include[8]: VAR N 1
    include[9]: +0000000000
    include[10]: VAR TMP 1
    include[11]: +0000000000
    include[12]: VAR DTA 990
    include[13]: +0000000000
    in this way
    VAR ZRO 1
    VAR I 1
    VAR SUM 1
    VAR AVG 1
    VAR N 1
    VAR TMP 1
    VAR DTA 990
    2) second array is dimensional array to read this part
    include[15]: READ N
    include[16]: LABL 20
    include[17]: READ TMP
    include[18]: GE TMP ZRO 40
    include[19]: SUB ZRO TMP TMP
    include[20]: LABL 40
    include[21]: PUTA TMP DTA I
    include[22]: LOOP I N 20
    include[23]: MOVE ZRO I
    include[24]: LABL 50
    include[25]: GETA DTA I TMP
    include[26]: ADD TMP SUM SUM
    include[27]: LOOP I N 50
    include[28]: DIV SUM N AVG
    include[29]: PRNT AVG
    include[30]: STOP
    in this way
    READ N
    LABL 20
    READ TMP
    GE TMP ZRO 40
    SUB ZRO TMP TMP
    LABL 40
    PUTA TMP DTA I
    LOOP I N 20
    MOVE ZRO I
    LABL 50
    GETA DTA I TMP
    ADD TMP SUM SUM
    LOOP I N 50
    DIV SUM N AVG
    PRNT AVG
    STOP
    3) the third to read this part
    include[32]: +0000000005
    include[33]: +0000000020
    include[34]: -0000000430
    include[35]: +0000000553
    include[36]: +0000001323
    include[37]: -0000000896
    in this way
    +0000000005
    +0000000020
    -0000000430
    +0000000553
    +0000001323
    -0000000896
    i hope i see some help
    [http://arbshare.net/files-182969.html]

    According to the file name ending with extension .tex, I guess that it's TeX, a markup language, not a programming language.
    Topicstarter: look for a more suitable forum. Good luck.

  • PLEASE HELP ME. THIS PROGRAM IS KILLING ME.

    Hi. I am getting so sick of this program. I have been trying to do it for the past couple of weeks and I am getting nowhere. I really wish someone can help me on it ... like totaly help me on it. I am getting so frustrated. I would appreciate all the help.
    This is the program:
    In Belageusia, a plorg has these properties:
    Data:
         A plorg has a name
         A plorg has a contentment index (CI), which is an integer between 0 and 100
    The population of plorgs in Belagersia is further subdivided into three mutually exclusive classes: Plebeians, Equidians, and Elitians.
    A Plorg?s stature is completely determined by their contentment index and witht that designation comes certain burdens and/or advantages.
    Plebeians have a contentment index in [0, 24].
    Each new Plebeian is welcomed with a contentment index of 2 and burdened with a debt of $10.00
    Plebeians never manage to break even, so they have no taxes imposed upon them. Furthermore, since they can never get out debt, they cannot accumulate any wealth.
    Equidians have a contentment index in [25, 75]
    Each new Equidian is welcomed with a contentment index of 50 and burdened with taxes of $20.00
    Equidians have taxes imposed upon them. Furthermore, since they do manage to break even, they have no debt. However, since they only manager to break even, they do not accumulate any wealth.
    Elitians have a contentment index in [76, 100]
    Each new Elitian is welcomed with a contentment index of 87 and burdened with taxes of $20.00, but also provided with a ?silver spoon? of $30.00 in accumulated wealth.
    Elitians manage to expand upon their wealth, sot hey have taxes imposed upon them. Furthermore, since they are accumulating wealth, they have no debt.
    At each interim time epoch the population of Belageusia retracts with a death rate randomly selected between 0% and 10%. If a plorg survives the purge, they have an opportunity to move one class higher and/or one class lower. However, remember that a plorg?s name is final. It never changes.
    For Plebeians this is transition is determined by randomly selecting a CI in [0, 49]. If this new CI is les than 25 then the plorg remains a Plebeian, with this newly assigned CI, and their debt increases 3.7%. If this new CI is in [25, 49], the Plebeian ascends to a Equidian, with this newly assigned CI, their debt is forgiven, but taxes of $20 are assessed.
    For Equidians this is determined by randomly selecting a CI in [0,100].
    If this new CI is in [25, 75] then the plorg remains a Equidian, with this newly assigned CI, but their taxes are increased 6.1%.
    If this new CI is in [0, 24] then the plorg becomes a Plebeian, with this newly assigned CI, their taxes are forgiven, but they are burdened with a debt of $10.00.
    If this new CI is in [76, 100] then the plorg becomes a Plebeian, with this newly assigned CI, but their taxes are increased 6.1%. However, they are bewtowed a wealth of $30.00.
    For Eletians this is determined by randomly selecting a CI in [51, 100]. If this new CI is greater than 76 then the plorg remains an Eletian, with this newly assigned CI, their taxes increase 6.1% and their wealth increases 4.9%. If this new CI is in [51, 75], then this plorg becomes an Equidian, with this newly assigned CI, their wealth is eliminated, and their taxes are increased 6.1%.
    At each time epoch, the population of Belageusia at a birth rate randomly selected between 0% and 10%. A randomly chosen number between 0-100 determines each newly born plorg?s stature. If this random number is in the range 0-24, create a new Plebeian. In the range 25-75, create a new Equidian, and if in the range 76-100, create a new Elitian.
    We are supposed to output the population characteristics of Belageusia, after 1000 time epochs.
    This is the code that I wrote down but got no where with:
    import javax.swing.*;
    import java.util.*;
    import java.text.*;
    public class Belageusiaplorg
         public static void main (String[] args)
              ArrayList Plebs = new ArrayList(350);
              ArrayList Equids = new ArrayList(600);
              ArrayList Elits = new ArrayList(350);
              ArrayList Holding = new ArrayList(600);
              for (int i=0; i<25; i++)
                   Plebs.add(new plebian());
              for (int i=0; i<50; i++)
                   Equids.add(new equidian());
              for (int i=0; i<25; i++)
                   Elits.add(new Elitian());
              long population = Plebs.size() + Equids..size() + Elits.size();
              System.out.println("Current Belageusia Population is "+population);
              System.out.println("Current Plebeians Population is "+Plebs.size);
              System.out.println("Current Equidians Population is "+Equids.size);
              System.out.println("Current Elitians Population is "+Elits.size);
              Random generator = new Random();
              int x = generator.nextInt(11);
              for (int j=0; j=plebs.size(); j++)
                   System.out.println(Plebs.g(j));
              long Equids_size = Equids.size();
              long Elits_size = Elits.size();
              for(int j=1; j<Plebs.size(); j++)
                   Plebian e = (Plebian) Plebs.get(j);
                   int new_ci = generator.nextInt(50);
                   if (new_ci < 25)
                        e.setCI(new_ci);
                        e.raiseDebt();
                   else
                        Plebs.rename(j);
                        Equids.add(new Equidian(e.getName().newCI));
                        j++;
              for(int j=0; j < Equids.size; j++)
                   Equidian e = (Equidian) Equids.get(j);
                   int newCI = generator.nextInt(101);
                   if(new_ci < 25)
                        Equids.remove(j);
                        Plebs.add(nwe Plebian(e.getName().new_ci));
                        Equids_size --;
                        j++;
                   else
                   if (new_ci > 75)
                        Equids.remove(j);
                        Elitian f = new Elitian(e.getName(),new_ci,e.getTaxes());
                        Elits.add(f);
                        Equids_size --;
                        j--;
                   else
                        e.setCI(new_CI);
                        e.raiseTaxes();
              for (int j=0; j<Elits.size; j++)
                   Elitian e = (Elitian) Elits.get(j);
                   int ci = e.getCI();
                   int r = generator.nextINT(50);
                   int new_ci = 51+r;
                   if(new_ci > 75)
                        e.setCI(new_ci);
                        e.raisetaxes();
                        e.raisewealth();
                   else
                        Elitians.remove(j);
                        Equidian g = new Equidian(e.getName(), new_ci);
                        g.raisetaxes();
                        Equids.add(g);
                        Elits_size --;
                        j--;
              if(deathrate != 0)
                   int multiple = 100/deathrate;
                   int count 1;
                   for (int j=0; j=Plebs.size(); j++)
                        if(count % multiple == 0)
                             Plebs.remove(j);
                             j--;
                        count++;
    class Plorg
         private final String name;
         private int CI;
         private static long nextID = 1;
         public Plorg()
              name = "Plorg" + nextID;
              nextID++;
         public Plorg(int CI)
              name = "Plorg" + nextID;
              nextID++;
              this.CI = CI;
         public Plorg (String name, int CI)
              this.name = name;
              this.CI = CI;
         public void setCI(int new_CI)
              CI = new_CI;
         public String getName()
              return name;
         public int getCI()
              return CI;
         public Plorg Plebs()
         public Plorg Equids()
         public Plorg Elits()

    Sounds a lot like a homework question to me. Still it was interesting enough to try out. I have not tried to change your code, just made one of my own. Here is my solution. I have made the Plorg class an inner class of the Belageusia. This is just so I dont have to put up two java files. You could easily split it into two though.
    import java.util.Random;
    import java.util.ArrayList;
    import java.util.Iterator;
    * @author Jonathan Knight
    public class Belageusia
        /** Random number generator - Seeded with the current time. */
        private static Random random = new Random(System.currentTimeMillis());
        /** A list of all of the Plorgs */
        private ArrayList population = new ArrayList();
        /** A list of all of the Plebians. */
        private ArrayList plebians = new ArrayList();
        /** A list of all of the Equidians. */
        private ArrayList equidians = new ArrayList();
        /** A list of all of the Elitians. */
        private ArrayList elitians = new ArrayList();
        /** A count of the Epochs that have passed */
        private int epochs = 0;
         * Main method.
         * Create a new world of Belageusia and run it for 1000 epochs.
        public static void main(String[] args)
            Belageusia world;
            world = new Belageusia();
            for (int i = 0; i < 1000; i++)
                world.epoch();
            System.out.println("The Belageusia population after 1000 epochs");
            world.printPopulation();
         * Create a new World of Belageusia and create some Plorgs to live there.
         * The world will be created with 25 Plebians, 50 Equidians and 25 Elitians.
        public Belageusia()
            for (int i = 0; i < 25; i++)
                plebians.add(Plorg.createPlebian());
            for (int i = 0; i < 50; i++)
                equidians.add(Plorg.createEquidian());
            for (int i = 0; i < 25; i++)
                elitians.add(Plorg.createElitian());
         * Print the current population to System.out
        public void printPopulation()
            int total;
            int plebianCount;
            int equidianCount;
            int elitianCount;
            plebianCount = plebians.size();
            equidianCount = equidians.size();
            elitianCount = elitians.size();
            total = plebianCount + equidianCount + elitianCount;
            System.out.println("Current Belageusia population is " + total);
            System.out.println("Current Plebian population is " + plebianCount);
            System.out.println("Current Equidian population is " + equidianCount);
            System.out.println("Current Elitian population is " + elitianCount);
         * At each interim time epoch the population of Belageusia retracts with a death rate
         * randomly selected between 0% and 10%. If a plorg survives the purge, they have an
         * opportunity to move one class higher and/or one class lower. However, remember that
         * a plorgs name is final. It never changes.
         * For Plebeians this transition is determined by randomly selecting a CI in [0, 49].
         * If this new CI is les than 25 then the plorg remains a Plebeian, with this newly assigned CI,
         * and their debt increases 3.7%. If this new CI is in [25, 49], the Plebeian ascends to a
         * Equidian, with this newly assigned CI, their debt is forgiven, but taxes of $20 are assessed.
         * For Equidians this is determined by randomly selecting a CI in [0,100].
         * If this new CI is in [25, 75] then the plorg remains a Equidian, with this newly assigned CI,
         * but their taxes are increased 6.1%.
         * If this new CI is in [0, 24] then the plorg becomes a Plebeian, with this newly assigned CI,
         * their taxes are forgiven, but they are burdened with a debt of $10.00.
         * If this new CI is in [76, 100] then the plorg becomes a Plebeian, with this newly assigned CI,
         * but their taxes are increased 6.1%. However, they are bewtowed a wealth of $30.00.
         * For Eletians this is determined by randomly selecting a CI in [51, 100].
         * If this new CI is greater than 76 then the plorg remains an Eletian, with this newly assigned CI,
         * their taxes increase 6.1% and their wealth increases 4.9%. If this new CI is in [51, 75],
         * then this plorg becomes an Equidian, with this newly assigned CI, their wealth is eliminated,
         * and their taxes are increased 6.1%.
         * At each time epoch, the population of Belageusia at a birth rate randomly selected between 0% and 10%.
         * A randomly chosen number between 0-100 determines each newly born plorg?s stature.
         * If this random number is in the range 0-24, create a new Plebeian. In the range 25-75, create a new Equidian,
         * and if in the range 76-100, create a new Elitian.
        public void epoch()
            ArrayList newPlebians = new ArrayList();
            ArrayList newEquidians = new ArrayList();
            ArrayList newEletians = new ArrayList();
            Iterator it;
            Plorg plorg;
            int deathRate;
            double deathCount;
            int birthRate;
            double birthCount;
            int population;
            int subClass;
            int newCI;
            int kill;
            epochs++;
            System.out.println("Epoch = " + epochs);
            printPopulation();
            population = plebians.size() + equidians.size() + elitians.size();
            // The death rate is random 0 to 10%
            deathRate = random.nextInt(11);
            // work out the death count. population is cast to a double to avoid rounding errors
            deathCount = (double)population * deathRate / 100;
            // round up the result. We do this as once the population falls below 10
            // we would never kill anything
            deathCount = Math.ceil(deathCount);
            // We now work out the birth rate based on the population before we kill
            // anything otherwise the population tends to go down and down
            // The birth rate is random 0 to 10%
            birthRate = random.nextInt(11);
            // work out the birth count. population is cast to a double to avoid rounding errors
            birthCount = Math.ceil((double)population * birthRate / 100);
            // As with the deathCount round up the result.
            // We do this as once the population falls too low we would never create any more
            birthCount = Math.ceil(birthCount);
            System.out.println("About to kill " + deathRate + "% which is " + deathCount + " Plorgs out of " + population);
            for(int i=0; i<deathCount; i++)
                // get a random number between 0 and 2
                kill = random.nextInt(population);
                population--;
                // kill the specified Plorg
                if( kill < plebians.size() )
                    // kill a random Plebian
                    plebians.remove( random.nextInt(plebians.size()) );
                else if( kill < plebians.size() + equidians.size() )
                    // kill a random Equidian
                    equidians.remove( random.nextInt(equidians.size()) );
                else
                    // kill a random Elitian
                    elitians.remove( random.nextInt(elitians.size()) );
            System.out.println("Transitioning Plebians");
            // Transition period for Plebians
            it = plebians.iterator();
            while ( it.hasNext() )
                plorg = (Plorg) it.next();
                // select a new CI from 0 to 49 at random
                newCI = random.nextInt(50);
                plorg.setCI(newCI);
                if( newCI < 25 )
                    // Oh dear, this one stays as a Plebian; increase its dept by 3.7%
                    plorg.setDept( plorg.getDept() * 1.037 );
                else
                    // Congratulations this one is now an Equidian
                    newEquidians.add(plorg);
                    // remove from the Plebian list.
                    // NOTE we must do the remove via the Iterator
                    it.remove();
                    plorg.setDept(0);
                    plorg.setTaxes(20);
            System.out.println("Transitioning Equidians");
            // Transition period for Equidians
            it = equidians.iterator();
            while ( it.hasNext() )
                plorg = (Plorg) it.next();
                // select a new CI from 0 to 100 at random
                newCI = random.nextInt(101);
                plorg.setCI(newCI);
                if( newCI < 25 )
                    // Oh dear, this one becomes a Plebian
                    newPlebians.add(plorg);
                    // remove from the Equidian list.
                    // NOTE we must do the remove via the Iterator
                    it.remove();
                    plorg.setDept( 10 );
                    plorg.setTaxes(0);
                else if( newCI < 25 )
                    // This one stays as an Equidian; increase its taxes by 6.1%
                    plorg.setTaxes( plorg.getTaxes() * 1.061 );
                else
                    // Congratulations this one is now an Eletian
                    newEletians.add(plorg);
                    // remove from the Equidian list.
                    // NOTE we must do the remove via the Iterator
                    it.remove();
                    plorg.setWealth(30);
                    // Increase its taxes by 6.1%
                    plorg.setTaxes( plorg.getTaxes() * 1.061 );
            System.out.println("Transitioning Elitians");
            // Transition period for Eletians
            it = plebians.iterator();
            while ( it.hasNext() )
                plorg = (Plorg) it.next();
                // Always increase taxes by 6.1%
                plorg.setTaxes( plorg.getTaxes() * 1.061 );
                // select a new CI from 51 to 100 at random
                newCI = 51 + random.nextInt(50);
                plorg.setCI(newCI);
                if( newCI > 76 )
                    // This one stays as an Eletian; increase its wealth by 4.9%
                    plorg.setWealth( plorg.getWealth() * 1.049 );
                else
                    // Oh dear, this one becomes an Equidian
                    newEquidians.add(plorg);
                    // remove from the Plebian list.
                    // NOTE we must do the remove via the Iterator
                    it.remove();
                    // emove its wealth
                    plorg.setWealth(0);
            // now assign the Plorgs that are transitioning
            plebians.addAll(newPlebians);
            equidians.addAll(newEquidians);
            elitians.addAll(newEletians);
            System.out.println("Creating " + birthRate + "% new Plorgs from " + population + " which is " + birthCount);
            //create the new Plorgs
            for (int i = 0; i < birthCount; i++)
                // get a random number between 0 and 100
                subClass = random.nextInt(101);
                // create the specified Plorg
                if( subClass <= 24 )
                    plorg = Plorg.createPlebian();
                    plebians.add(plorg);
                else if( subClass >= 25 && subClass <= 75 )
                    plorg = Plorg.createEquidian();
                    equidians.add(plorg);
                else
                    plorg = Plorg.createElitian();
                    elitians.add(plorg);
        public static class Plorg
            /** Identifier used to generate unique names */
            private static int id = 0;
            /** The Plorgs name */
            private final String name;
            /** The level of wealth for this Plorg */
            private double wealth = 0;
            /** The level of dept for this Plorg */
            private double dept = 0;
            /** The level of taxes for this Plorg */
            private double taxes = 0;
            /** This Plorgs contentment index */
            private int ci = 0;
            /** Create a new Plorg with the given CI.
             * This is a private constructor. The only way for a program to
             * create new Plorgs is by calling either createPlebian(),
             * createEquidian() or createElitian().
             * @param ci
            private Plorg(int ci)
                // Generate a unique name and iincrement the ID
                this.name = "Plorg" + id++;
                // assign the CI
                this.ci = ci;
             * Create a new Plebian.
             * Plebeians have a contentment index in [0, 24].
             * Each new Plebeian is welcomed with a contentment index of 2 and burdened
             * with a debt of $10.00. Plebeians never manage to break even, so they have
             * no taxes imposed upon them. Furthermore, since they can never get out debt,
             * they cannot accumulate any wealth.
             * @return a new Plebian.
            public static Plorg createPlebian()
                Plorg plebian;
                plebian = new Plorg(2);
                plebian.setDept(10);
                return plebian;
             * Create a new Equidian
             * Equidians have a contentment index in [25, 75].
             * Each new Equidian is welcomed with a contentment index of 50 and burdened
             * with taxes of $20.00. Equidians have taxes imposed upon them. Furthermore,
             * since they do manage to break even, they have no debt. However, since they
             * only manager to break even, they do not accumulate any wealth.
             * @return a new Equidian.
            public static Plorg createEquidian()
                Plorg equidian;
                equidian = new Plorg(50);
                equidian.setTaxes(20);
                return equidian;
             * Create a new Elitian.
             * Elitians have a contentment index in [76, 100].
             * Each new Elitian is welcomed with a contentment index of 87 and burdened
             * with taxes of $20.00, but also provided with a ?silver spoon? of $30.00 in
             * accumulated wealth. Elitians manage to expand upon their wealth, so they
             * have taxes imposed upon them. Furthermore, since they are accumulating
             * wealth, they have no debt.
             * @return a new Elitian.
            public static Plorg createElitian()
                Plorg equidian;
                equidian = new Plorg(87);
                equidian.setWealth(30);
                equidian.setTaxes(20);
                return equidian;
             * Returns this Plorgs name.
            public String getName()
                return name;
             * Returns the CI of this Plorg.
            public int getCI()
                return ci;
             * Set the new Contentment index for this Plorg
             * @param ci
            public void setCI(int ci)
                this.ci = ci;
             * Returns the Dept of this Plorg
             * @return
            public double getDept()
                return dept;
             * Set the dept of this Plorg.
             * @param dept - the new dept for the Plorg.
            public void setDept(double dept)
                this.dept = dept;
             * Returns the wealth of this Plorg.
            public double getWealth()
                return wealth;
             * Sets the wealth of this Plorg.
             * @param wealth - the new wealth of this Plorg.
            public void setWealth(double wealth)
                this.wealth = wealth;
             * Returns the taxes of this Plorg.
            public double getTaxes()
                return taxes;
             * Set the taxes of this Plorg.
             * @param taxes - the new taxes for this Plorg.
            public void setTaxes(double taxes)
                this.taxes = taxes;
             * Check for equality. If the object specified is a Plorg with the same name as this
             * Plorg they are deemed to be equal.
             * @param o - The object to check
            public boolean equals(Object o)
                if ( this == o ) return true;
                if ( !(o instanceof Plorg) ) return false;
                final Plorg plorg = (Plorg) o;
                if ( name != null ? !name.equals(plorg.name) : plorg.name != null ) return false;
                return true;
             * Create a Hash Code for this Plorg
            public int hashCode()
                return (name != null ? name.hashCode() : 0);
    }

  • Needs help.....Please about using different classes

    I don't know how to use differenet classes.
    Please tell me how to write class to suit Start. This stuff me up. Please .... help me
    <<My program>>
    //Start
    public class Start
    {  private Artist[] Artists;
    private Record[] records;
    private Person[] Manager;
    private TextMenu makeMenu = new TextMenu();
    public static void main(String[] args)
         Start studio = new Start();
    studio.menu();
    public Start()
    {  //Person.Manager(ManagerName,HouseNumber,StreetNumber,PhoneNumber)
         Manager = new Person[1];
         Manager[0] = new Person("Yangfan",88,"Young ST",11118888);
         //Artist(GroupID,ArtistName,HouseNumber,StreetNumber,PhoneNumber)
         Artists = new Artist[5];
    Artists[0] = new Artist(1,"Backstreet Boys",58,"Music ST",99998888);
    Artists[1] = new Artist(2,"Santana",68,"Music ST",99998899);
    Artists[2] = new Artist(3,"Macy Gray",78,"Music ST",55558888);
    Artists[3] = new Artist(4,"Ricky Martin",88,"Music AVE",77778888);
    Artists[4] = new Artist(5,"Did Rock",55,"Music Road",66667777);
    //Record(RecordingID,RecordName,Artist,StartTime,FinishTime,RecordingDate,GuestArtist1,GuestArtist2)
    records = new Record[6];
    records[0] = new Record(1,"I want it that way",Artists[0],11,12,"05/08/2001",Artists[1],Artists[3]);
    records[1] = new Record(2,"Smooth",Artists[1],11,12,"05/08/2001",Artists[1],"");
    records[2] = new Record(3,"Do something",Artists[2],11,"05/08/2001",Artists[3],"");
    records[3] = new Record(4,"Livin La Vida Loca",Artists[3],11,12,"05/08/2001",Artists[1],Artists[3]);
    records[4] = new Record(5,"Bawitdaba",Artists[4],11,13,"05/08/2001",Artists[1],"");
    records[5] = new Record(6,"The one",Artists[0],11,14,"05/08/2001",Artists[1],"");
    public void menu()
    {  String[] choices = {">>>List Manager Details",">>>List All Artist Names",">>>List An Artist Telephone-Number",">>>Show Details For One Recording",">>>Add A New Recording",">>>List The Recording Costs For All Artists",">>>List Artist's Reocording",">>>Exit Program"};
    while (true)
    {  switch (makeMenu.getChoice(choices))
    {  case 1: showAllArtists();
    break;
    case 2: showAllRecords();
    break;
    case 3: System.exit(0);
    break;
    case 4: System.exit(0);
    break;
    case 5: System.exit(0);
    break;
    case 6: System.exit(0);
    break;
    case 7: System.exit(0);
    break;
    case 8: System.exit(0);
    break;
    default:
    public void showAllArtists()
    {  int numArtists = Artists.length;
    for(int i = 0; i < numArtists; i++)
    {  Artists[i].displayArtistDetails();
    public void showAllRecords()
    {  for (int i = 0; i < records.length; i++)
    {  System.out.println();
    records.printRecordDetails();
    <<Assignment>>
    Due - midnight, Wednesday August 22nd
    This assignment will test your knowledge of Java programming using classes, encapsulation and javadoc.
    The base requirements
    Write a complete Java class to manage a Digital Recording Studio. The studio wants to keep a list of all Artists that use the studio and also wishes to keep track of all Recordings that have been made. An important function of the program is to calculate the time spent making a recording and charge the Artist for the time used.
    You must create at least the following classes, Start, Studio, Person, Artist, Recording, Address. You may create other classes if needed as well
    Start will contain main(), create one instance of a Studio and execute a Menu of commands to test your code. Studio should contain a studio name, an array of Artist and an array of Recording plus the studio manager (a Person). Each Artist should contain the name of the group and an Address. Each Person will have a name and a home address. Each recording will have a Title (usually song title), an Artist (only one), and a list of guestArtist (they are Artist�s but will not receive royalties) the number of the CD the recording is stored on (numbers are numerical and recordings are saved on CD-R), plus the recording start and finish times for the recording session (suggest you use Java Date class � refer to the API). An Address will contain, house number (integers only), a street name and a telephone number. There is no need to store city and country.
    To enter a set of data for testing your program � main() should call a method in the Start class that will fill in a set of values by creating objects and filling in values by calling methods in each class. This is the ONLY method allowed to be longer than 1 page long � normally we would read the data from a file but there are no O-O principles that can be learnt with simply filling in data values. It is suggested to create say at least 4 Artist�s and 6 Recordings (at least one with 1 guest Artist and one with 2 guestArtist�s)
    A menu for testing your program should be provided (it is suggested to put the Menu into a separate class as you need at least 3 menus). While other commands are possible, only the following ones will receive marks.
    Menu commands needed are
    List the Managers name, address and telephone number
    List all Artist Names
    List an Artist telephone number (a sub menu showing valid Artist�s is required)
    Show all details for one Recording ( sub menu of valid Recordings will be needed and remember there can be more than one guestArtist)
    Add a new Recording, user will need to be prompted for all details.
    List the recording costs for all Artists � show each Artist on a separate line with their name and total amount, charge for using the studio is $1000 per hour or part thereof, example for a 1 hour and 10 minute recording the Artist will be billed for 2 hours.
    List all the Recording�s one Artist has worked on (sub menu of Artists needed), the list should show whether they were the Artist or a guestArtist
    Exit program
    Use fixed sizes for arrays, suggest 20 is suitable for all arrays. Java can handle dynamic data structures (where the number of elements can grow or shrink), but that is beyond a first assignment.
    Do NOT make ANY methods static - this defeats the Object Oriented approach and will result in ZERO marks for the entire assignment.
    Data MUST be encapsulated, this means that all the data relating to an object are to be stored INSIDE an object. None of the data detail is to be globally available within your program - hence do not store Artist names in either Studio or Recordings � just store a reference instead. Do NOT create ID numbers for Artists, you should use References instead � for many students this will be the hardest part as you have to use Objects, not program in a C style to solve the problem. Note that if there are any non-private data in classes then zero will given for marks for encapsulation.
    Good programming style is expected (see web page or lecture notes). In particular, you must use javadoc to generate a set of html pages for your classes. Make sure you use the special javadoc style comments in your source code. Marks will be granted for both using javadoc and also for including sensible javadoc comments on each class and each public method.
    What to Hand In
    Read the turnin page, basically the .java files, a readme.txt to tell the marker which file the program starts from plus the javadoc (html) files. Do NOT send .class files (if you do send these we will delete them and recompile your program), do NOT compress with gtar, tar, zip or use any other tool on your files. Turnin automatically compresses all your files into a single archive for us to mark.
    The simplest way to turnin all your files is to place all files in one directory then just use the *.* wildcard to turn in all files within that one directory.
    You must turnin all files that are not part of Java 1.3. In particular, you are allowed (actually encouraged) to use EasyIn or SavitchIn but should include the one you use in the files you submit. It is STRONGLY suggested that you copy all the files into another directory, test it works there by compiling and executing then turnin files from that directory. A common problem is students adding comments at the last minute then not testing if it still compiles. The assignment will be marked as submitted � no asking later for leniency because you added comments at the last minute and failed to check if it still worked.
    If the tutors are unable to compile your submission, they will mark the source code but you will lose all the execution marks. Sorry, but it is your responsibility to test then hand in all files.
    Comments
    For CS807 students, this program should be fairly easy if it was to be programmed in C (you would use several struct). The real art here is to change over to programming objects. Data is contained in an object and is not global. This idea is essential to using Java effectively and is termed encapsulation. Instead of using function(data), you use objectName.method( ). Effectively you switch the data and functions around, the data has a method (function) attached to it, not the other way around as in C (where you have a function and send data to it).
    While there will be some marks for execution, the majority of the marks will be given for how well you write your code (including comments and documentation) and for how well you used O-O principles. Programs written in a C style with most of the code in one class or using static will receive ZERO marks regardless of how well they work.
    You are responsible for checking your turnin by reading the messages turnin responds with. Failure to read these messages will not be an acceptable excuse for submitting an incorrect assignment. About 2% of assignments sent to turnin are unreadable (usually empty) and obtain 0.
    Late submissions
    Late submissions will only be accepted with valid reasons for being late. All requests for assignment extensions must be made via email to the lecturer. Replies for acceptance or refusal will made by email. Instant replies are unrealistic (there is usually a flood of queries into my mail box around assignment due dates) and the best advice is to ask at least 4 days in advance so that you will have a reasonable chance of getting a timely reply and allow yourself enough time to submit something on time if the extension is not granted.
    ALL late submissions will be marked LAST and will NOT be sent to tutors for marking until all other assignments have been marked. As an example, if you submit late and your assignment is not yet marked by the time assignment 2 is due then it will be pushed to the end of the marking pile as the assignments that were submitted on time for assignment 2 will take priority.
    If you make a second submission after the submission date, only the first submission will be marked. We will not mark assignments twice! You can update your submission BEFORE the submission date if you need to - this will just overwrite the first submission. The latest time for a late submission is 5pm on the Wednesday after the due date. This is because, either a solution will be handed out at that lecture or details of the assignment will be discussed at the lecture. I cannot accept any assignment submissions after that time for any reason at all including medical or other valid reasons. For those who are given permission to be later than the maximum submission time � a different assignment will be handed out. Remember, if you decide to submit late you are VERY UNLIKELY to receive feedback on your assignments during semester.
    Assignments will be removed from turnin and archived elsewhere then forwarded to tutors for marking on the morning after the assignment is due. A different tutor will mark each of your assignments � do not expect the tutor you see at the tutorials to be your marker.
    Marks will be returned via email to your computer science yallara account � ideally within 2 weeks. I will send marks out when I receive them so do not send email asking where your marks are just because a friend has theirs. If you want your email forwarded to an external account, then place a valid .forward file into your yallara account. The Help Desk on level 10 can assist you in setting this up if you do not know how to do it.

    I have seen other people who have blatantly asked for
    other people to do their homework for them, but you
    are the first person I've seen to actually cut and
    paste the entire assignment as it was handed to you.
    Amazing.
    Well, unlike some of the people you're talking about, it seems like zyangfan did at least take a stab at it himself, and does have a question that is somewhat more sepcific that "please do this homework for me."
    Zyangfan,
    marendoj is right, though. Posting the entire assignment is kind of tacky. If you want to post some of it to show us what you're trying to do, please trim it down to the essential points. We don't need to see all the instructor's policies and such.
    Anyway, let me see if I understand what you're asking. You said that you know how to write the code, but only by putting it all in one class, is that right? What part about using separate classes do you not understand? Do you not know how to make code in one class aware that the other class exists? Do you not know how code in class A can call a method in class B?
    Please be a bit more specifice about what you don't understand. And at least try using multiple classes, then when you can't figure out why something doesn't work, explain what you did, and what you think should have happened, and what did happen instead.
    To get you started on the basics (and this should have been covered in your course), you write the code for two classes just like for one class. That is, for class A, you create a file A.java and compile it to A.class. For class B, you create a file B.java and compile it to B.class. Given how rudimentary you question is, we'll skip packages for now. Just put all your class files in the same directory, and don't declare packages in the .java files.
    To call a method in class B from code that's in class A, you'll need an object of class B. You instantiate a B, and then call its methods.
    public class B {
      int count;
      public B() { // constructor
      public void increment() {
        count++;
    public class A {
      public static void main(String args[]) {
        B b = new B();
        b.increment();
    }Is this what you were asking?

  • Need help with a rudimentary program

    I'm sort of new at this so i need help with a few things... I'm making a program to compile wages and i need answers with three things: a.) what are the error messages im getting meaning? b.) How can i calculate the state tax as 2% of my gross pay with the first $200 excluded and c.) how can i calculate the local tax as a flat $10 with $2 deducted for each dependant. any help is appreciated
    Here is what i have so far:
    public class WagesAsign1
              public static void main(String[] args)
                   int depend=4;
                   double hrsWork=40;
                   double payRate=15;
                   double grossPay;
                   grossPay=payRate*hrsWork;
                   double statePaid;
                   double stateTax=2.0;
                   statePaid=grossPay*(stateTax/100);
                   double localPaid;
                   double localTax=10.0;
                   localPaid=grossPay*(localTax/100);
                   double fedPaid;
                   double fedTax=10.0;
                   double taxIncome;
                   fedPaid=taxIncome*(fedTax/100);
                   taxIncome=grossPay-(statePaid+localPaid);
                   double takeHome;
                   System.out.println("Assignment 1 Matt Foraker\n");
                   System.out.println("Hours worked="+hrsWork+" Pay rate $"+payRate+" per/hour dependants: "+depend);
                   System.out.println("Gross Pay $"+grossPay+"\nState tax paid $"+statePaid+"\nLocal tax paid $"+localPaid+"\nFederal tax paid $"+fedPaid);
                   System.out.println("You take home a total of $"+takeHome);
    and these are the error messages so far:
    WagesAsign1.java:23: variable taxIncome might not have been initialized
                   fedPaid=taxIncome*(fedTax/100);
    ^
    WagesAsign1.java:29: variable takeHome might not have been initialized
                   System.out.println("You take home a total of $"+takeHome);
    ^

    edit: figured it out... please delete post
    Message was edited by:
    afroryan58

  • Need help with threads?.. please check my approach!!

    Hello frnds,
    I am trying to write a program.. who monitors my external tool.. please check my way of doing it.. as whenever i write programs having thread.. i end up goosy.. :(
    first let me tell.. what I want from program.. I have to start an external tool.. on separate thread.. (as it takes some time).. then it takes some arguments(3 arguments).. from file.. so i read the file.. and have to run tool.. continously.. until there are arguments left.. in file.. or.. user has stopped it by pressing STOP button..
    I have to put a marker in file too.. so that.. if program started again.. file is read from marker postion.. !!
    Hope I make clear.. what am trying to do!!
    My approach is like..
    1. Have two buttons.. START and STOP on Frame..
    START--> pressed
    2. check marker("$" sign.. placed in beginning of file during start).. on file..
         read File from marker.. got 3 arg.. pass it to tool.. and run it.. (on separate thread).. put marker.. (for next reading)
         Step 2.. continously..
    3. STOP--> pressed
         until last thread.. stops.. keep running the tool.. and when last thread stops.. stop reading any more arguments..
    Question is:
    1. Should i read file again and again.. ?.. or read it once after "$" sign.. store data in array.. and once stopped pressed.. read file again.. and put marker ("$" sign) at last read line..
    2. how should i know when my thread has stopped.. so I start tool again??.. am totally confused.. !!
    please modify my approach.. if u find anything odd..
    Thanks a lot in advance
    gervini

    Hello,
    I have no experience with threads or with having more than run "program" in a single java file. All my java files have the same structure. This master.java looks something like this:
    ---master.java---------------------------------------------------
    import java.sql.*;
    import...
    public class Master {
    public static void main(String args []) throws SQLException, IOException {
    //create connection pool here
    while (true) { // start loop here (each loop takes about five minutes)
    // set values of variables
    // select a slave process to run (from a list of slave programs)
    execute selected slave program
    // check for loop exit value
    } // end while loop
    System.out.println("Program Complete");
    } catch (Exception e) {
    System.out.println("Error: " + e);
    } finally {
    if (rSet1 != null)
    try { rSet1.close(); } catch( SQLException ignore ) { /* ignored */ }
    connection.close();
    -------end master.java--------------------------------------------------------
    This master.java program will run continuously for days or weeks, each time through the loop starting another slave process which runs for five minutes to up to an hour, which means there may be ten to twenty of these slave processes running simultaneously.
    I believe threads is the best way to do this, but I don't know where to locate these slave programs: either inside the master.java program or separate slave.java files? I will need help with either method.
    Your help is greatly appreciated. Thank you.
    Logan

Maybe you are looking for

  • Unable to upload the PAR from NWDS

    Hi , I am unable to upload the par from NWDS as it is throwing the error "Unable to upload" I have done the proxy settings in NWDS. can any one tell me is there any other settings i have to do in NWDS. Thanks Ajay

  • N96 Firmware Updates

    I have got N96 today and I want to update the firware from v12 to v20 but FOTA says v30 is available,please any help about this cuz under v30,the feature is supported.I prefer v20 to 30 Solved! Go to Solution.

  • To avoid duplicate values in DrowpDownByIndex

    hi Iam calling an RFC ,it's output is as following column 1 column2    A             2    A              3    A             42    B              34    B              3    B              11    B               0 Iam displaying these values in two combo

  • Document types for ledger group

    Hello gurus, Document types have been defined differently for leading ledger and non leading ledger.  Now our client want to use same document type for both leading & non-leading(document type using for non-leading ledger want to use for leading ledg

  • Performance problem of program RFITEMAP

    Hello all, if I select my  interval for  company code  largely, the program (RFITEMAP) is very slow.  What  I can make in this report, so that preformance becomes better. Example: ( selection criterion ) company code : 1           to    200   - > ver