BestJewSinceJC 700 Posting Maven

Oh. It's because when you're going forward, you said something like:

while (node != null) node = node.next()

Which guarantees that once you get out of that loop, "node" is equal to null. So you can use an additional Node variable to store the current Node (before you assign it to node.next()) or you can change your while loop so that it prints out node.next() and checks that node.next() != null instead of printing out Node.

BestJewSinceJC 700 Posting Maven

As masijade said, a newline is almost always "\n" so you'd just add "\n" into the String. Or you can say System.out.println() more than once since it automatically adds a newline at the end of your String.

BestJewSinceJC 700 Posting Maven

im just having trouble with creating the word class and i dont understand what it means when he says "use a LinkedList
of Word objects." and how to check if a word from the file is a word on the list

Your word class is correct except that where you have the "?" it should use the String class's equals method. For example:

String something = "blah";
String somethingElse = "bleh";
if (something.equals(somethingElse)){
//In your case, you'd return true; in here.
System.out.println("Equal!");
}

As for the LinkedList, your teacher means for you to do this:

LinkedList<Word> list = new LinkedList<Word>();

As for why you put the <Word> in brackets like that, it is called Generics. So if you google Java Generics and read some articles, or if you want to check out these:
http://tutorials.jenkov.com/java-generics/index.html
^ Simpler but slightly worse tutorial
http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
^ Better tutorial but not light reading.

BestJewSinceJC 700 Posting Maven

I believe the set and get methods are used for code reusability...?

Not particularly. They're more useful for encapsulation - hiding your data and only making their use available through methods that you (the programmer) implement. For example, you might want to encapsulate a data member "hours" and provide a set method that only allows a user of your class to set hours to an integer from 1-12. After all, you probably don't want the hour to be anything else.

BestJewSinceJC 700 Posting Maven

For amount of time worked, just subtract end hour - start hour and end minute - start minute. You'll need an extra two arrays to record the results. You'll also need to account for the possibility that end minute is < start minute.

Also the program should output the average amount of time worked. Be sure to use good programming style. Modularization & arrays are required.

Someone should tell your teacher that "good programming style" is impossible without using Objects for this problem. Using Objects for this problem is essential to code readability, maintainability, ease of programming, and modularity. I actually think it's funny that your teacher used the word modularity but apparently he/she doesn't know what it means.

For example: Resources about modularity in Object Oriented programming:
http://java.sun.com/docs/books/tutorial/java/concepts/object.html

BestJewSinceJC 700 Posting Maven

On second thought, after reading more of your teacher's project description, he/she already gave you basically the exact steps required to do this project. What step, exactly, are you having trouble with? And a step isn't "I can't do this" its very specific: for example, can you not iterate over the list? Do you not know how to figure out if an element is equal to another element? (Which I already told you). Etc.

BestJewSinceJC 700 Posting Maven

Steps to do your project:

1. Make a main class (You've already done this and posted it).
2. Make a class called Word.
3. The 'Word' class should have two instance variables: 'String theWord' and 'int count'. The 'Word' class should have a constructor that takes a String and an int and assigns them to theWord and count.
4. The 'Word' class should also have an isEqual method that returns true if the word passed in is the same as the String 'theWord' and returns false otherwise. To do this you can use the String class's equals method (just FYI, an equalsIgnoreCase method also exists, but since your teacher already converted toLowerCase it doesn't matter).
5. For your main class (mostFrequentWord) you need to have an instance variable 'LinkedList wordList'. Each time you read in a new word from the text file, you need to search the entire wordList. If the word is already in the wordList, you add 1 to its count. If the word in not in the wordList, you create a new Word Object using the constructor I mentioned earlier, and you pass in the word and a count of 0. To 'search the entire wordList' you need to use the method your teacher was talking about earlier: you need to use an iterator:

//Pseudocode
for each item in the list:
if (item.equals(currentWord))
increment that item's count
else make a new Word Object with count 0.
BestJewSinceJC 700 Posting Maven

Reflection is used for a class to examine its own (or another class's) behavior at runtime. For example, while the program was running, you could determine what methods the class has and invoke those methods.

You can find the source code file by figuring out the class name and locating the file with the name "classname.java". You can probably use getResource to find the .java file, although it can be complicated. If, for some reason, you do not know the class name (which you probably should know in advance) you can use the printClassName() example found at the top of the Class documentation.

If you know the String name of the class (like MyClass.java and you have the String "MyClass") then you can use the Class method "forName" to get a Class Object for it. Again, look at the documentation link I sent you on that.

To get the source code the easiest way is what I mentioned above - figure out the name of the class, which you probably know in advance, append ".java" to it using String concatenation, then open the .java file for reading, read in the contents, and display them somehow.

Salem commented: Nice +20
BestJewSinceJC 700 Posting Maven

Can you give a short example text file, and tell us how the records would be created for that text file? Because the design that your teacher gave you makes no sense. Why would you pass the name of a text file to 'Concordance' only to pass the same name to 'Record' over and over? How are you supposed to know what you already read in from the text file and what remains to be read in from the text file? Without passing more information to the Record constructor, there is no reasonable way to do this. (If that doesn't make sense to you, just give a short example text file and show me how the Records should be created for it).

BestJewSinceJC 700 Posting Maven

Your description is of a one dimensional array where the goal is to find the minimum number in blocks such that the number is greater than or equal to the current job. But your code creates a two dimensional array. Why?

BestJewSinceJC 700 Posting Maven

Mod queues always sound a good idea, unless you are one of the mods who actually have to police the things. Speaking from experience, I can say that they create much more work than they save. They also penalise decent members who are looking for a quick answer to an urgent problem but find that the question does not even get published for 24 or 48 hours because a mod has to work through the queue to reach it, along with dealing with other mod duties. So such a solution would, in my opinion, work against us in creating more work for mods and driving members to other forums.

Agreed, it is a bad idea. But working through the queue wouldn't be an issue; having a mod online at all times would be the problem.

BestJewSinceJC 700 Posting Maven

The difference is that Turbo C has not had an update in more than a decade.

Please tell me you guys are both aliases and this is a joke. How many times do people with experience in a language have to tell you that something (TurboC) is inferior before you believe them? IMO at this point you deserve whatever crappy education you get. If you google "Turbo C" the first result says "Antique Software". Enough said. Learn how to program in something relevant.

jephthah commented: yup +0
BestJewSinceJC 700 Posting Maven

Write out the project description and tell us, step by step, what you think you will need to do for each part. If we think you're wrong we can help but show effort or you'll get no help.

BestJewSinceJC 700 Posting Maven

You need a closing ). And why would you make a new Scanner that scans the string [COLOR="Green" anyway? That doesn't make any sense. Is that what you meant to put there?

BestJewSinceJC 700 Posting Maven

Your explanation is over my head since I have no experience in those areas, but out of curiosity, is meeting with some companies and getting estimates out of the question for some reason?

But what I do know is that you're unlikely to get an accurate estimate of how much time the project will take unless you go into a lot more detail about what the project will need to do. What are the requirements of the project -- what information do you expect to be produced by the program, what are your sources of data from which it pulls, etc. For example, what kind of provisioning tools are you looking for, what do you want them to do? I don't even know what provisioning tools are, but if they vary in either type or amount, how could someone possibly provide a time estimate without you describing the type and amount that you are looking for?

BestJewSinceJC 700 Posting Maven

Thanks for that enlightening and philosophical reply.

Nick Evan commented: :D +12
BestJewSinceJC 700 Posting Maven

http://www.javaworld.com/javaworld/javaqa/2003-08/01-qa-0808-property.html

The resource can be placed in one of many directories, I think one of these is in the same directory as the .class file. Read the article for more accurate information.

Also see loading resources using getResource
http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html

BestJewSinceJC 700 Posting Maven

Iam3R:

Sorry, I didn't mean to dig up old threads. Its just that at the time, I had just studied the exact same problem and I *think* my professor made the claim that it wasn't doable without memoization (of the solutions in here, none use a dynamic programming approach afaik). It has been awhile since then, but I'm still hoping someone on here will confirm or deny that suggestion.

edit: I found some links elsewhere that say I'm wrong, http://geeksforgeeks.org/?p=576 .

BestJewSinceJC 700 Posting Maven

Well apparently the last part is not correct. I just checked the API and it doesn't say such thing. It simply returns true or false if the next token is int BUT the the next token is not a new line. It is when you enter value. The new line, or many empty spaces followed by <ENTER> at the keyboard doesn't constitute as next token. Look at the description of the method:

You might be saying the same thing, but just to clarify, the nextInt() method reads in the next token that is preceded and followed by the delimiter pattern. By default this pattern matches whitespace, so what this means is that as long as any amount and any kind of whitespace precedes and follows an integer, the nextInt() method will successfully read in that integer. This includes spaces, tabs, and newlines...

BestJewSinceJC 700 Posting Maven

What is the problem? You just start at the last node and work your way back. It is the same code as going forward except you use the 'back' Node instead of the 'next' Node and you stop when back == null and you start at the end instead of the front.

BestJewSinceJC 700 Posting Maven

There is a C code forum... this is not it

BestJewSinceJC 700 Posting Maven
for (int x = 0; x < intValue.length; ++x)

Should probably be

for (int x = 0; x < intValue.length; x++)

The same for your other for loop. That is more than likely the reason you're getting the exception.

BestJewSinceJC 700 Posting Maven

Like jwenting said, there are many concepts in OOP and Java that are more important to learn than what you're trying to do. If you're insistent, here's how you could at least learn an important concept along the way. If you make a class that extends JPanel (inheritance), you could add your own setImage method. Then when you used your class in the future, you could do things like JPanel.setImage("imagePath.jpg").

http://java.sun.com/docs/books/tutorial/java/IandI/subclasses.html

BestJewSinceJC 700 Posting Maven

Read the announcement at the top of the forum.

Oh, and get gmail. If you really need your msn hotmail account, forward all emails from it to your gmail account. PS "enabling your internet" - how could that be a problem to begin with, if your internet is already enabled? I guess you meant disables.

BestJewSinceJC 700 Posting Maven

I also cannot figure out how to implement an accumulator in this program. My friend told me a switch statement needs to be created, but I have no idea how to do that in the main method?

Fix your printf errors first. Whether or not it produces an error message doesn't matter. There are logical errors and compiler errors. Your program has both right now, it is important to get rid of them. And I don't know what an accumulator is .

BestJewSinceJC 700 Posting Maven
System.out.printf("%d. %-20s\n", average);

Like I said, similar errors all over. You either have the wrong type of argument or the wrong number of arguments. You're doing this all over the place. You told it to expect an integer followed by a String, but you only passed in "average" (which I'm assuming is an integer).

System.out.printf("%d. %-20s\n", average, "");

You have to pass it a String if you put %s.

BestJewSinceJC 700 Posting Maven
BestJewSinceJC 700 Posting Maven

Ok. Who's stopping you?

BestJewSinceJC 700 Posting Maven

You're using printf incorrectly.

System.out.printf("%d. %-20s\n", POTTER_NUM, POTTER_NAME, POTTER_PRICE);
System.out.printf("%s", "What is the tax rate for this transaction (in percent)? ");

Only the first one would cause an error, but the second one should just be the second String - you have no need to say %s instead of just quoting the String, do you?

In the first one, it might be complaining because you have three arguments but only two format specifiers (i.e. the %d and %s are format specifiers).

You have similar errors all over.

BestJewSinceJC 700 Posting Maven

Doable, but a bad idea unless you're trying to create some sort of library of common functions that you use. If that is what you're going for create some static methods in a different class where you can call those methods from your paint method. Pass in your Graphics object or whatever objects you need to pass around.

If you're only doing this to remove bloat, don't do it though. Removing bloat isn't a good reason to introduce overhead and complicate the code more.

BestJewSinceJC 700 Posting Maven

What is the error message.

BestJewSinceJC 700 Posting Maven

I don't know - what are you missing? Did you do any debugging? You listed some steps:

1. input 10 integer numbers,
2. display the numbers,
3. modify a specific number I have already entered,
4. display the updated numbers again.

Which of those steps isn't working?

BestJewSinceJC 700 Posting Maven

Thank you for your reply, Rather than going back to the more basic approach that you have suggested, I have managed to refined my current code and got it doing more along the lines of what I am after,

No problem. As a lot of the other posters here probably know, I'm pretty partial towards Scanner. Either way, both approaches are pretty simple, and I'm glad you got it to work.

:)

BestJewSinceJC 700 Posting Maven

That explanation makes it more confusing, if anything. What we need in order to help you:

1. Explain what problem you are having.
2. A minimal code sample demonstrating the problem.
3. An explanation of what the code sample is supposed to be doing.
4. An explanation of what the code is currently doing.

As far as I can tell, you have given us none of that information.

BestJewSinceJC 700 Posting Maven

Just use Scanner to read in the file.

Scanner input = new Scanner(System.in);
System.out.println("Course to match");
String course = input.next();
Scanner file = new Scanner(yourFilename);
while (file.hasNext()){
String courseID = file.next();
if ( // check if the course ID matches the course the user is looking for){
System.out.println( // print the rest of the current line; check out nextLine() method );
}
}

Hope that code snippet helps. I'm expecting that you will need to modify it to do anything substantial, but hopefully that will give you a start.

BestJewSinceJC 700 Posting Maven

http://userpages.umbc.edu/~dhood2/courses/cmsc433/spring2010/?section=Notes&topic=Ruby&notes=07

The above is a good resource.

As far as your code, it looks ok, except you should be passing the file name to the File.file? method. Like

File.file?(aFile) then if it is actually a regular file, rename it.

BestJewSinceJC 700 Posting Maven

We don't need to, we assume sarcasm is your MO

:p

BestJewSinceJC 700 Posting Maven

You just did post a thread...

jephthah commented: haha, he did, didnt he? +0
BestJewSinceJC 700 Posting Maven

get a degree indeed, and also don't be afraid of taking on jobs that don't fit your "ideal" job description.

Agreed, but also the OP should learn the skills necessary to qualify for a large quantity of jobs, to maximize his chances of getting one. And that means learning java or other object oriented languages.

BestJewSinceJC 700 Posting Maven

http://www.csee.umbc.edu/courses/undergraduate/341/spring09/projects/proj5/HuffmanExplanation.html

Is that helpful at all? One of the projects I did in school. I don't know if that is "static" huffman coding or adaptive... I always assumed it was the only huffman coding TBH.

BestJewSinceJC 700 Posting Maven
BestJewSinceJC 700 Posting Maven

I'm torn between liking you and hating you. Hmpf!

BestJewSinceJC 700 Posting Maven

Most of your 2000 posts do not help with programming, they are mainly giving a link to the API, discussing TV or making criticisms. Makes one wonder do you actually know much about programming or are you just one of those people who thinks forum post counts are very important to them as you seem to "mock" my 18 posts.

This isn't about my level of programming skill or yours. The important thing is learning how to ask questions well and showing effort, not expecting people to do your work for you.

BestJewSinceJC 700 Posting Maven

Ok that's fine but... what problems are you having then? You just posted code with no additional information.

BestJewSinceJC 700 Posting Maven

... Yes. And if that answers your question, mark this thread solved.

BestJewSinceJC 700 Posting Maven

Nice fake signature. Also, for the second time in the last few days, surely you realize that your sentence is missing a preposition? I'll help you out: next time say "Please give me some suggestions". Or you could use a relevant topic title instead of telling us what we already know - that you need help with something.

BestJewSinceJC 700 Posting Maven

Your calculations appear correct, your method of displaying them appears incorrect.

JOptionPane.showMessageDialog(null, input + total);

Saying input + total concatenates input and total into a String which then gets displayed to the user. So for example if the user inputs "10" and the total money should be .70 cents, your code might display "100.70" to the user.

BestJewSinceJC 700 Posting Maven

Learn about Regular Expression Syntax and then you can implement into all programming langugaes... :)

Regular expression syntax isn't standardized, different languages may have their own regex syntax, a subset of another language's syntax, or a regex package that mostly implements another language's syntax but adds features or has different syntax for certain things. But regex syntax is often similar in completely different languages.

BestJewSinceJC 700 Posting Maven

You see the code button at the top of the reply box? Click it, then insert your code in the middle of it.

BestJewSinceJC 700 Posting Maven

Why do you want to make it into a 2d char array, and how? As far as I know StringBuffer is represented by an underlying char array. How do you want to make it into a 2d one?