javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all no one is going to spend his precious time trying to understand what you are writing in the way you are writing it. Not even you don't use code tags, but also I cannot understand if you are posting two different files (classes) or one, or where you methods start and finish.
Try to write it better with spaces and don't do this:
{DVD ....

do this:

{
  DVD ...
}

even though it is programmatically wrong. This is the correct

public DVD ( /*arguments*/ ) {
...
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

And when you are receiving an error, that you don't know in a line where you are calling a lot methods one inside another, try to break it a bit:

String stringToParse =  line.substring (line.indexOf(","),line.length());

System.out.println(stringToParse);

int num = Integer.parseInt(stringToParse );
blocksArray [numBlocks][1] = num ;

In that way it is easier to find your error: System.out.println(stringToParse);

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Here is a sample of your code:

Object  newGymUser = new Object();
        
          boolean b = alreadyExists(newGymUser );   //error here
        if (b) {
                    System.out.println("Cannot insert existing user");
                } else 
                {
                        UserListIn.add(newGymUser );
                }
                GymUser newGymUser = new GymUser(tempUserrID, tempName, tempID, tempSurname, tempAddress, tempPhone, tempAge,tempDuration);
                boolean b = alreadyExists(newGymUser );
                if (b) {
                            System.out.println("Cannot insert existing user");
                        } else 
                        {
                            UserListIn.add(newGymUser );
                       }
        
        UserListIn.add(new GymUser(tempUserrID, tempName, tempID, tempSurname, tempAddress, tempPhone, tempAge,tempDuration));

Why do you call UserListIn.add() 3 times??????????????

And what is this: Object newGymUser = new Object();
The object is GymUser

Don't you understand what are you writing?
You are creating a new Object: Object newGymUser = new Object(); Checking if it exists in order to add it or not, AND then you do the same thing with :GymUser newGymUser = new GymUser(.....);
And after you are done, again you are calling the add.

Just create ONE object: GymUser newGymUser = new GymUser(.....); with arguments the ones that you have from the keyboard, and check this if it exists or not in order to add it.
And do it once.

I would suggest that you implement the bollean alreadyExists(GymUser user) in the class UserListIn. And if you are going to use ArrayList, or HashTable declare it in UserList and use methods to access it: like you are doing with add()

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I will add some more code after a few hours, with better explanations

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Can't you READ??? First you create a new object, then call the alreadyExists, and then call add.
You are calling add and then you are calling the alreadyExist and then you are doing another add. Does this make sense to you? By the way you are not creating the newGymUser object.

You have to implement the alreadyExists.

You have to create a global ArrayList where you will store the Gym Users objects

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You will have an ArrayList. (Read the API) Before you do an add, you will read all the existing users and compare their IDs with the new one. If it does not exist then inserted.

http://java.sun.com/j2se/1.5.0/docs/api/overview-summary.html

Try the util package

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I already told you where to put it. Just create a method that returns boolean and has a GymUser argument, that checks whether the input gymUser's id already exists among the other users that are already stored. By the way, where do you store the other users?(ArrayList, Vector?)

GymUser newGymUser = new GymUser(tempUserrID, tempName, tempID, tempSurname, tempAddress, tempPhone, tempAge,tempDuration);
boolean b = alreadyExists(newGymUser );
if (b) {
  System.out.println("Cannot insert existing user");
} else {
 UserListIn.add(newGymUser );
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Inside the: UserListIn.add(GymUser newGymUser) method you will take the new Gym User and compare him with the other gymUsers. If one with the same id already exists then don't add him and print a message or throw an Exception.
If you don't want to make this check inside the .add method, then before calling it, take all the other users and compare them with the new user. If the new user doesn't have the same id, then call your method.
By the way, if you are using a database, and the table already is created with a primary key then you don't need to check anything because an SQLException will be thrown and the new user won't be inserted

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I believe that you should write a return statement at the end of your "public static int calcFib (int n)" method. From what I have seen you have return statements in all of your if () { }, but I think that in some versions of the java you need to have a return outside of the if. Try this and If I was wrong, send the line that the error happened. And try to write using code tags.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You cannot move one TextField to another. If you want to change focus, use the focusListeners, and/or the keyListeners.
I think there is a method at TextField that sets the focus.
If you want to write to a text Field something from another use the getText(), setText() methods. Also check the API for more details about the syntax

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What exception, where is it thrown, what is the message? And what is your question????? The title of the post is not meant for asking questions

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I also don't think that this correct:

public double GreatCircleDistance(lat, lon, alt) {

}

Shouldn't be :

public double GreatCircleDistance(double lat,double lon,double alt) {

}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

It's seems to me that you already have some ideas. If you don't like them then we cannot know what you would like to do. By the way, what YOU would like to do? Find that out and then Just Do It

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all why create two classes that do the same thing: UserInput1,UserInput2?
Just create only one that prints the message: "Give a number" and create two different instances:

UserInput1 firstNumber = new UserInput1();
int input1 = firstNumber .getUserInput1();

UserInput1 secondNumber = new UserInput1();
int input2 = secondNumber .getUserInput1();

//firstNumber , secondNumber  two different instances

As far you error, the getCalculateNegOrGreater is declared void. It does not return anything, it just prints.
So why you write:
int negGreater = negOrGreater.getCalculateNegOrGreater(Input1, Input2); ?

What is it supposed to return? The getUserInput1 in the UserInput1 class returns something that's why you wrote: int input1 = firstNumber .getUserInput1();
Just write:

negOrGreater.getCalculateNegOrGreater(Input1, Input2);
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all create a Job object like I told you. Then a method that takes as argument the Jobs (array,vector, or anything else you want with Job objects) and write your code there.
Do you know how to sort an array because I think you have to do something similar (It's been a long time since I used a Shortest Remaining Time First algorithm for my OS subject)

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I drink hot chocolate while I am writing code, and potato chips with coke when playing video games

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Assuming that you want to sort an array of numbers then declare your array, read from the input then numbers and store each one of them in the array and then call a method that sorts the array:
For reading I use this:

BufferedReader USERIN = new BufferedReader (new InputStreamReader(System.in));
USERIN.readLine();

If you search this forum you will find other ways to read from the input.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}

Personally, I don't use very often this kind of way to read files, but why don't you try what masijade has suggested with renaming the file. Do you have access to the JAva API?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Why don't you post your code, the exception that was thrown and the stack trace. How are we supposed to understand what is the problem? Ask the Oracle from the Matrix:icon_wink: ?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Sorry I am a little confused. Each entry in the java list is in the format: XXXXX,XX/XX/XXXX

So if I use String.split(",") it would return an array of Strings as follows:

XXXXX,XX/XX/XXXX,XXXXX,XX/XX/XXXX... is this correct?

If you use split for the XXXXX,XX/XX/XXXX:

String s="XXXXX,XX/XX/XXXX";
String [] tokens =s.split(",");

then tokens[0] will be: XXXXX
and tokens[1] will be: XX/XX/XXXX

Check the API in case it would be better for you to use the String.split( "," , -1 ) version. (I think this is used in case after the "," there are no other characters. I don't really remember very well)

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I don't think it makes any difference. They both work for what he needs them.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

No, no, no. The way I see it each Card object must represent a single card the suit, rank must not be arrays. The constructor will take the 2 values and you will pass these values to your class attributes.
Both attributes will be Strings. You will have no problem with suit. Just remember at the constructor to check: if the input suit is not “SPADES”,”DIAMONDS”,”CLUBS”,”HEARTS”, then throw an Exception or print an error message.
As for rank:
Now remember the constructor's rank will be int.
if the argument is between 2 and 10 just turn the int into a String

this.rank = String.valueOf(rank); //it will the int rank(argument) into a String and store it into the this.rank(String attribute of the class)

if it is 1,11,12,13 then put the necessary if-statements in order to store what is needed to rank. Then create 52 different Card objects (use 4 for-loops) and you have yourself a deck

piers commented: thnx 4 ur help +1
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Well, if you think it's better he should use ArrayLists then.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Create an Animal class:

public class Animal {
  private String description;
  private String name;
  //appropriate constructor and get, set methods. Perhaps a toString() method
}

Then create another class in which you declare you LinkedList. The list might be private, and the class will have methods to add, get, remove Animal objects.
Personally I prefer the Vector class
ex:

//inside the second class:
private Vector v=new Vector();
//plus some other methods, constructor

public void add(Animal a) {
  v.add(a);
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Sorry for this new reply, I was checking something. About this environment variables, go:
Right click on My Computer
Properties
Advance Tab
System(Environment) Variables
Choose CLASSPATH.
I have this: ;C:\Program Files\Java\j2re1.4.2_12\bin; in my system. You should probably put the path where you have installed your own version of java. If it doesn't work try to added int the Path variable as. I really don't remember where it should be put. I only did it once when I installed and I don't have my book with me. But If you had a decent Java book it should explain how to set these variables

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What do you mean referencing an array from another class? What are you trying to do?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have you set the environment variables? You have to state where the javac command is. Also if you open the command prompt and type java it should print the java version you are using.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What do you mean prove it? You DON'T have to prove, it is just the way it is. Do you mean implemented using recursive?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Compile it, I think if you are console the command is >javac InputHandler.java (if I remember correctly because for a very long time I have been using IDEs) and run it with the command
>java InputHandler
Then the program will print the message in your code and then just insert the input.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

quarters, dimes, nickels, pennies must be int

quarters= int(change/25);
dimes= int(change/10);
nickels= int(change/5);
pennies= int(change/1);
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you want to write html just create a new file with the extension .html or .jsp and write your code in there using the appropriate tags.
As for importing a project, you should its .jar file in order to added at your current project's library

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You cannot run an Applet using main(String [] args)
You must use an HTML page.
And I think I've seen the same question to another thread, that had the same answer.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I cannot tell much without the code. But I know for sure that at the specific line there is something which is null and you use it

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

This is part of the stack trace:
BasicTreeUI.paintRow(BasicTreeUI.java:1399)
It means that at the file BasicTreeUI.java, you have an Exception at line 1399 (function paintRow). You are trying to use something that is null.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Your class must extend the Thread class and implement the run method. (void run())
When your class runs that method it is executed in parallel with any other thread, included the main(String [] args).
So just create a class that stores the random numbers in an array. Code must go in the run().
Call two instances of this class. When you call their run() methods they will be executed in parallel.
When they are done use a second class to take those arrays and do the sorting.
Don't forget to have a boolean to check when they are both(the classes the generated the numbers) done because if you call the second class for the sorting right after the threads then it will be executed without the generation of the random number being finished.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

A good tutorial about html can be found here : http://www.w3schools.com/

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Correct me If I am wrong but I have a feeling jwenting, that he is supposed to use the specific algorithm for calculating the binary number. I think it was meant for homework but I don't know for sure

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The while statement is correct. You don't need the A; it is in the Q where you store your input and that's what you want to modify. If you look your code you will see that you write Q=A/2 without giving any values to A in the first place.
You should write something like:

R=Q%2;
Q=Q/2;

If you write the Q=Q/2 first, and then the R=Q%2, then the R will not have the correct value because the Q would have been altered and then you would try to get the modulus of the wrong Q.
Then you must store the R in a String value using the concat operator "+" inside the while loop, because you calculate a new R each time and you don't save it anywhere:

Outside the loop: String result="";

Inside the loop you must have one of these two:

result=result+R;

or

result=R+result;

You must decide which one is correct

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What????? NetBeans released the 6.0? That's amazing. I am still using the 0.0.0.0.1 version:icon_lol: I am going to download it with my PSTN 28kbps connection. By the time it gets downloaded, the 7.0 will be released :icon_lol:

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Right-click the file and choose the extract option. Then open the folder that you got and search for some .jar files. Then follow the instructions I sent you about those jar files

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Click the "start new thread" link/button at the page where you view all the posts

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Right above the text area where you write your reply there are tools for writing in bold or underlying. The 3rd from the right which is a "#" symbol is the code tag. Click it and write your code inside the tags.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I have downloaded the zip files and if you extract them you will see that inside the folders there are some .jar files as well as other files containing some source. Perhaps when they built the library they zipped the entire folder and post it for download. Now I don't know which jars it is required to use but in Eclipse there should be an option where you can add these jar files in your java build path. I don't know if we are using the same version, but in mine, if you go: Project, Properties, Java Build Path, Libraries, you should be able to add those jar files. Try and search all the folders that you extracted in case you miss some jar files. I think you should also write import the packages in your code.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

When you say that you downloaded them, in what form did you get them? (Perhaps a .jar file)

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try something like this:

(int)Math.pow(y,2);

or

System.out.println((int)Math.pow(y,2));

if you want to print

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

It will return false. 4 cannot be divided by 8 and 16 cannot be divided by 32

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Returns true if each "father" can be divided by each of their "sons". false even if one of the fathers cannot be divided by theirs sons. If a node is null, it does not check it and returns true.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Finally, this is first time I've seen in this forum someone start a thread with the title:'Need help' and not asking for the solution to his homework without having written any code for himself.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If C++ is your language then you are at the wrong forum