fred rosenberger

lowercase baba
+ Follow
since Oct 02, 2003
fred likes ...
Chrome Java Linux
St. Louis
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by fred rosenberger

 if (month=2&&isLeapYear(_year)=true&&day<=1&&day>=29)

you realize that a single '=' is an assignment, not a comparison?  so you are trying to assign the value of "true"  to what you got back from your method call...which is just wrong.
You are also assigning the value of 2 to month, and then trying to use the "2" in a boolean expression.  

Also, you should never compare a boolean to "true" or "false",  you just use it.  You probably need something like:

 if (month==2 && isLeapYear(_year) && day<=1 && day>=29)
1 day ago

Stephan van Hulst wrote:you could open the executable with a hex editor and do a search for the magic number CAFEBABE

on a unix system, you could just use the "strings" command and a grep.
3 days ago

Amol Araragi wrote:, so it basically allows us to use arguments in cmd?

exactly.  remember, "main" is a function, just like every other function.  it just happens to be the one the JVM calls to start your program.  So, as a function, it takes a String Array as its argument.  the array can be empty, or can have as many arguments as you want/need.  What you do with them, or how you use them, is entirely up to you.
4 days ago
it's a way to get arguments into the program from the command line.  if your class with the main() method is called "foo", you could do this on the command line:

>java foo argument1 argument2 argument3

with as many arguments as you want.  The all get stored in that "args" array, which you can then pull apart and used the values in your program.  
4 days ago

Mike London wrote:It can look totally foreign in a few months or even weeks.

Shoot, when you reach my age, it's a few hours...
1 week ago
so I would ask...what is your real goal here?  Are you trying to re-arrange the cards in the specific order as Campbell listed, or are you trying to randomly re-arrange them, like a riffle-shuffle does?  in the real world, it is almost impossible to do a perfect riffle, which is why the cards end up randomized.
4 weeks ago

Junilu Lacar wrote:I have never seen building elevators with a floor 0 button.

I've never see a floor 0, but I have see "Ground" or "Lobby", followed by  1, 2, 3...  then I've seen "LL1", "LL2", etc. for "lower level" floors below ground.
1 month ago
1) forget about java.  Forget about programming.  
2) think through the problem.  pretend you have to explain it to a young child.  How would you tell them what to do?
3) think about what you need to know.  things like: Where is the elevator car right now?  What is the top floor?  What is the bottom floor?  what do i do if the input takes me beyond the range?  Do I really need to store every floor in an array, or do i just need to know the max and min. floors, along with where I am?

Once you've thought through all this, THEN start thinking about java.

I don't see the need for an array at all.  If i know the car.currentFloor == 7, building.maxFloor == 10, and building.minFloor == -2, I can test the input to see if it takes me beyond the acceptable range.  If so, give an error, if not, update the currentFloor.
1 month ago
as a general rule, you would not want to use a floating type when dealing with money.  you will inevitably get weird rounding errors.  You would want to deal with whatever your currency's base unit is.  For U.S. dollars, your base unit would be the penny.  so if something costs $8.50, you would want to represent that as 850 (pennies).  When you display it, you can convert it to whatever format you want.  
2 months ago
what is your definition of "truly random"?  Using java, you can get random-seeming numbers - i.e numbers that are equally distributed across a range and that are (almost) impossible to predict.  But any pure-code implemented algorithm is pretty much guaranteed to not be completely random, since anyone who a) knows the algorithm, and b) knows the seed will be able to reproduce the sequence.
2 months ago

Marr Yenn wrote:My caps lock was left on never turned it off

and that's why i have physically removed the caps lock keys from my keyboards...
2 months ago
just to clarify a bit more, since you may see this kind of error again....

You defined your "calculating" method like this:

That's line 33 in your original post.  this says "I am hereby saying that there will be a method called 'calculating'.  To use it, an integer array must be given to it.  When it is done, it will spit back a double value".

That's all well and good.  But then on your line 12, you try an call a method called "calculating", but don't give it an integer array.  Java doesn't know what to do. The only method with that name REQUIRES an integer array - so it complains. It says "I don't know of anything named 'calculating' that can be executed with no parameters".  

Basically, the method name and the list of parameters it takes is called the method signature.  The calling line must match some version that is actually defined, and your original code doesn't have that.

Note:  Campbell's advice is still correct, re: best OO way to do things.  But even if you do create an object with height and weight, your method signatures must match.
2 months ago
Line 15 in the original code is printing the difference between the values of two elements.  since there are three total elements, you get two differences - the difference between element 0 and 1, and then the difference between element 1 and element 2

Your code is just printing the value of a single element.  So for a three element list, you'd get three values.

There is nothing wrong, per se, with either.  It's a question of what do you want in your output.
2 months ago

Piet Souris wrote:When I was in primary school (1962-1968) we had the sentence: Meneer Van Dam Wacht Op Antwoord, meaning powers, multiplication, division, square roots, addition, subtraction. It didn't mention parentheses, but the answer would have been 1. Like 3 - 3 + 3 would have been -3. But then came these computers, spoiling it all...

We used "Please Excuse My Dear Aunt Sally" - Parentesis, Exponents, Multiplication, Division, Addition, Subtraction.  However the problem there is this implies all multiplication comes before all addition.  I was taught multiplication and division go in order, left to right, and you do them all before you do the addition/subtraction in order, left to right.

that makes sense, since multiplication and division are really the same operation, as are addition/subtraction.

but your phrase really confuses me.  You did square roots AFTER multiplication?  what about cube roots, or fractional roots?  and roots are again the same thing as powers, so why do they come so late?  if you has a power of 3/2, do you do it as a power or as a root?  PLEASE don't tell me you'd cube it, then multiply/divide, and THEN do the root.  that would break my brain.
2 months ago
don't just start writing code.  spend a LOT of time thinking, sketching, and playing with ideas.  Document any assumptions you make (i.e. the data will be English; the data will be in a random order as opposed to mostly sorted).  Strive for clean, readable code over clever or hyper-efficient code.  Remember that someone, someday, will have to read your code and understand it. You don't want them to have to spend days trying to figure out some clever trick that saved a user a microsecond.

2 months ago