713 Posted Topics

Member Avatar for tj0101

Well, look at tuition. Apparently it's 0.0 when you print it. What happens to it before you print it? How does it get that value? And what happens before that? How does it get the preceding value? Work back through the code this way and you should be able to …

Member Avatar for jon.kiparsky
0
349
Member Avatar for SolidSora

You can simplify Taywin's method by starting your flag at 1, and multiplying by -1 at each boundary. Then just add the flag to the current total, and you've eliminated the middle if. You can do simplify further by just counting and then flipping. [CODE]public static void main(String[] args) { …

Member Avatar for jon.kiparsky
0
3K
Member Avatar for dynaflex

Okay, let's look at the logic of the thing. As you have it now, your calculate method has one serious flaw in it. Walk through the logic manually - what happens if I want to buy 15 slices? If you correct that error (it's a simple fix) then you have …

Member Avatar for alexsmth114
0
212
Member Avatar for lynnajoe

When you pass an object o to println() as its parameter, it typically tries to print it by calling String.valueOf(o) to get a String value. That value is going to be the value returned from calling o.toString(). If that object overrides Object.toString(), then that return value will be whatever the …

Member Avatar for lynnajoe
0
100
Member Avatar for SMITA6076

setHoursWorked is a void return - it doesn't return a value. You can't assign anything to setHoursWorked(), because there's nothing to assign. The best thing to do would be to return the calculated value and leave the assignment, not set "hoursWorked" from within the method. Same problem for setPayRate.

Member Avatar for jon.kiparsky
0
293
Member Avatar for subith86

That didn't seem right to me, so I tried it. Here's the code: [CODE] public static void main(String[] args) { System.out.println(true?ifTrue():ifFalse()); } public static String ifTrue() { return "It's twue, it's twue"; } public static String ifFalse() { return "You liar!"; }[/CODE] And the output: It's twue, it's twue I …

Member Avatar for subith86
0
133
Member Avatar for SavnetSinn

First thing in debugging is to identify the actual problem. In this case, it's one that every programmer in a C-type language commits early on, and I'm going to let you find it yourself, because the facepalm you will undergo will mean you never make this mistake again. The most …

Member Avatar for jon.kiparsky
0
153
Member Avatar for abz2010

Sorry, but nobody here is likely to do your homework for you. If you're having trouble with code you've written, post the code and I'm sure you'll find some assistance. To get started on a project like this, identify the entities involved - who does what and with which and …

Member Avatar for jon.kiparsky
0
139
Member Avatar for lynnajoe

There are a few underlying things you need to understand. One is that an array is a collection of items, and each element of the array is a single item. Another thing is that you'll have an easier time of it if you handle your data, logic, and presentation separately. …

Member Avatar for jon.kiparsky
0
86
Member Avatar for server_crash

[QUOTE=ajst;1407385]what you can do is rather then running the inner loop to the same number as the outer loop get it to stop at half of the outer loop. that way it will not create duplicates or have to waste time comparing if its in list allready [/QUOTE] Doesn't help …

Member Avatar for Momerath
0
162
Member Avatar for insanely_sane

[QUOTE]prolly just a memory address[/QUOTE] That'll be right. An array is an object. If you feed an object as the argument to a print or println, it'll generally try to print it by calling String.valueOf(the object). That behavior is defined in the API, under String: [QUOTE] valueOf public static String …

Member Avatar for jon.kiparsky
0
2K
Member Avatar for z00t

Start by charging $250. For each visit over 5, charge $55. That is, if visit > 5, add (visit-5)*$55 to the $250 initial fee. Here's one of the things you might want to iron out: [CODE] while ((visit >= 0) && (visit <= 5) { total = flatRate; } [/CODE] …

Member Avatar for jon.kiparsky
0
162
Member Avatar for dawnoflife

To read this stack trace, look at the first line you see. That'll tell you what exception is being thrown, in this case an InputMismatchException. Since this is a Java object produced by Sun, it's [URL="http://download.oracle.com/javase/1.5.0/docs/api/java/util/InputMismatchException.html"]documented[/URL] and you can read up on what Sun has to say about it. The …

Member Avatar for jon.kiparsky
0
190
Member Avatar for eltonpiko

Translation is actually quite a hard problem. I don't think you're going to solve it with simple search/replace. I heard an interesting talk last year by someone working in this area, and it sounds to me like most of the serious machine translation out there relies more on statistical matching …

Member Avatar for jon.kiparsky
0
1K
Member Avatar for Phinocio

This code here doesn't actually open or write to a file, so it's hard to say what your error might be. It's very possible that it's something to do with the file mode, as Taywin suggests, or some other error, but here all you do is identify a file and …

Member Avatar for jon.kiparsky
0
151
Member Avatar for Java_tyro

Start by figuring out what the steps are at a high level, then figure out how to execute them. Executing them may, and probably will, involve decomposing them into steps which you'll then re-examine in the same way until you have methods which are trivial to execute. Write the trivial …

Member Avatar for jon.kiparsky
0
217
Member Avatar for Rakesh Mall

I'm sure there are practical uses that others will be happy to detail. The pedagogical use, though is worth mentioning: I'm learning assembly to understand the machine better, and to get a better handle on what I'm doing in C. I don't think I'm going to generate any non-trivial code …

Member Avatar for Taywin
0
113
Member Avatar for emcyroyale

[CODE]Homework3.compareTo(al.get(i));[/CODE] Homework3 is a class. It can't be compared to a Homework3 object, any more than you can compare the Integer class to the Integer 3. Calling a method in the form ClassName.method() is calling it as a static method - it's calling it without reference to any particular object …

Member Avatar for emcyroyale
0
194
Member Avatar for chess2009

[QUOTE=Momerath;1493627]How can you own them and not be responsible for them? [/QUOTE] Nothing very odd about this. When I look at, say, my old DAW science fiction anthologies, I see that the copyright page lists the magazine of first publication as the copyright holder, but nobody would ever suggest that …

Member Avatar for Ezzaral
0
367
Member Avatar for 54uydf

1) Yes, it's possible. What'll happen is the first value will be overwritten, though, which isn't what you want. I'd look again at your structure. If person to phone number is a one to many relationship, perhaps you want to map names to arraylists of phone numbers. If there are …

Member Avatar for 54uydf
0
115
Member Avatar for lsvife

That's correct. Notice, however, that you're going to have to commit an act of minor barbarism, using a try/catch as a conditional. That is, you're going to put the parseInt in a try block, and if it returns an exception, you're going to take that as a "false". Since there …

Member Avatar for mKorbel
0
122
Member Avatar for HesterSuma2007

You'd need something like cbreak mode, which I think you can't get in the console under java. Same reason you can't clear the screen, except by sending a large number of carriage returns.

Member Avatar for HesterSuma2007
0
163
Member Avatar for gedas

You want the first iteration of the loop to be different from the rest of the iterations? James' boolean flag is one acceptable way to do that. The execution cost of checking that value and then setting firstPass to false at the end of each loop is negligible. However, stylistically, …

Member Avatar for gedas
0
100
Member Avatar for kaylee10

Popular discussion lately. There are IDEs available for Java. Eclipse is probably the most popular, and it's pretty usable. NetBeans is popular as well, I haven't used it. Both are free. There are others as well. However, I'd suggest that you use an editor and compile direct from the command …

Member Avatar for Taywin
0
98
Member Avatar for blahbla

When in doubt, try doing it by hand and see what steps you need to take. Here's a random collection of coins: 3 quarters, two dimes, three nickels, and two pennies. Here's another random collection: 4 quarters, 4 dimes, 1 nickel, and 1 penny. Here's another random collection: 1 quarter, …

Member Avatar for blahbla
0
431
Member Avatar for eoop.org
Member Avatar for jon.kiparsky
0
296
Member Avatar for NicAx64

[QUOTE=frogboy77;1451378]It appears to be the case of those who can, do, those who can't, teach.[/QUOTE] It appears to be the case that there's a lousy teacher in the world. Are you surprised? In my time, I've seen a lot more lousy students than lousy teachers... and usually the lousy students …

Member Avatar for Momerath
0
251
Member Avatar for hairpull

Look at your while clause: [CODE]while (userNumber >= 0)[/CODE] Under what conditions will that continue to loop? So why doesn't it loop when you want it to? Look at the break at line 22 - what does that mean? There are two idiomatic ways to do a while loop. One …

Member Avatar for jon.kiparsky
0
128
Member Avatar for Java NOOB

I'm hesitant to leap in here, but there's a bit of confusion that should be cleared up. In ztini's post, he says that "invoking .equals checks whether or not the memory locations are equas". This is true, [b]if[/b] you have not written a .equals() method for your class, and assuming …

Member Avatar for jon.kiparsky
0
153
Member Avatar for RastaC

[url]http://en.wikipedia.org/wiki/Standard_score[/url] Don't thank me. Thank google. First entry under "z-score". Try it some time, it's pretty cool.

Member Avatar for ztini
0
104
Member Avatar for gekkoswave

1D is a line. 0D is a Point. If you want to do this OO style, you could make a case for starting for 0D Tic Tac Toe - "Tic" you'd call it, I guess - and working out from there. I bet you he won't do it that way, …

Member Avatar for ztini
0
305
Member Avatar for ChieftanBill

The out of bounds is simple enough. You're going to i<args.length, which is correct. But then in the loop, you're addressing args[i++] - this means you're addressing args[length] in the last time through. That address doesn't exist, so there's your outofboundsexception. The sort you're describing is more or less a …

Member Avatar for jon.kiparsky
0
153
Member Avatar for ahmed_fawzy

Simpler explanation: [url]http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html[/url] Simpler explanation than that: float is 32-bit, double is 64-bit. Simplest explanation: just use double and ignore float.

Member Avatar for JamesCherrill
0
151
Member Avatar for insanely_sane

A tokenizer turns a raw input sequence into a sequence of "tokens", which your parser can then accept for further processing. It will often attempt to recognize keywords and return "tokens" of that type, and return unrecognized items as literals - so [CODE]if (a == b) { c = d; …

Member Avatar for Progr4mmer
0
225
Member Avatar for jimJohnson

If you want to understand java, skip the IDE, get a proper text editor, and compile from the command line. Once you're developing larger applications, it might make sense to start using an IDE, but for now features like auto-completion, syntax highlighting, and the like will only insulate you from …

Member Avatar for Progr4mmer
0
140
Member Avatar for wonder_laptop

[QUOTE=wonder_laptop;1486498]i dont see where i can integrate this in my code..[/QUOTE] If I understand priteas, he's suggesting you make an arraylist of Integer, populate it with integers in the range you want, and remove(randomIndex) for your random numbers, randomIndex being a random int in the range (0..arraylist.size()) Instead of [ICODE]idx …

Member Avatar for jon.kiparsky
0
262
Member Avatar for jfountai

Am I correct in thinking the whole thing is an array of Strings, each row is a String? If so, you can use Java's regex which is not too far from perl's. The major difference is that regexen are created as Strings, which means you have to worry about escaping …

Member Avatar for jfountai
0
175
Member Avatar for CMAUK

[QUOTE]The simplest solution would be to write out a new file with the updated data and delete the original one[/QUOTE] Seconded. Read in the file, modify it in memory, write it out when you're done, overwriting the original. Write out a backup of the original first if you're concerned about …

Member Avatar for jon.kiparsky
0
3K
Member Avatar for privatestatic

The return statement error is not hard to spot, although it would be easier if you tried to simplify your code a little. One way to find this is to trace the logic of that method - make sure that every branch leads to a return statement. You should find …

Member Avatar for jon.kiparsky
0
150
Member Avatar for i_me_roo

I will be happy to explain the answer - your confusion here is actually reasonable - if you'll be kind enough to a)start a new thread for this question, since we don't like new questions in old threads, it's contrary to the house style and b) put code tags around …

Member Avatar for jon.kiparsky
0
951
Member Avatar for techie929

Previous poster is absolutely correct. Absolute index of an array arr[] must be in the range [0..arr.length-1] - can't be negative, can't be equal to or greater than the length. Notice I say "absolute index" - that's the index that the compiler sees as the value. Now, suppose you want …

Member Avatar for jon.kiparsky
0
97
Member Avatar for coolbeanbob

Java will not accept a method that is not part of a class. The only things that have methods are classes and objects (classes have static methods, like [CODE]public static void main (String args[])[/CODE] and objects have instance methods like [CODE]public String toString()[/CODE] That's the way it is. Why not …

Member Avatar for jon.kiparsky
0
154
Member Avatar for magikkar2nd

localArrayList.add(arrayOfgz[j] = = paramArrayOfgz[j]); Can you explain what you mean for this line to do? localArrayList is a raw ArrayList, so I've go no clues from the declaration what it is you mean to add here. Are you trying to assign from the paramArray to the array and then add …

Member Avatar for jon.kiparsky
0
589
Member Avatar for carlitosway17

[CODE] } // end method sphereVolume } // end constructor [/CODE] There's no method "sphereVolume", so one of these ends the constructor and the other ends the class.

Member Avatar for Taimoor Rana
0
296
Member Avatar for Dani

Speaking of "humor doesn't always come across well" - there are mature and experienced php developers? Who knew? :)

Member Avatar for jon.kiparsky
0
210
Member Avatar for manish250

manish- read [URL="http://www.catb.org/~esr/faqs/smart-questions.html"]this [/URL] Remember, make it easy for people to help you out. Style matters!

Member Avatar for manish250
0
180
Member Avatar for cypher1

Someone who promises to cover all of that in one day might be promising too much. I could tell you how each of those things work over the course of six or eight hours, but most of it requires a certain amount of time at the machine to make sense. …

Member Avatar for Progr4mmer
0
167
Member Avatar for ajst

Do you mean something like the fireActionPerformed() method found in AbstractButton?

Member Avatar for JamesCherrill
0
97
Member Avatar for patrickgormally
Member Avatar for techie929

When you create a Vector without a type, it's automatically a Vector<Object> - that is, when you get() something from the vector, all the compiler knows is that it's an Object. When you add() your ints, they're auto-boxed into Integers, which are of course Objects. Fine so far. When you …

Member Avatar for jon.kiparsky
0
100

The End.