Sean Heise

Greenhorn
+ Follow
since Oct 30, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sean Heise

Popped I could declare a new variable set to two and then do like Fib[var++]?
5 years ago

Campbell Ritchie wrote:The website I asked about avoiding doesn’t come up. I shall try to edit your post, because I think there is a spelling error in the link.

There are people who take programming courses because they want to program and people who think they have to as a part of a larger course. But you might as well get the best mark you can.
You achieve two things by banging your head against a keyboard. A damaged computer and a headache.
If you stepped back and got a piece of paper and wrote something like this on it, you would see what I meant by starting at No 2.You have to put it in code tags on this website to get the numbers aligned. If you stepped back and worked out the algorithm, you could work out the workings of your array in a few minutes. And you could avoid getting annoyed with yourself and everybody else.
Fred, Bear and Dennis are right.
It is quicker to start from scratch, working out the algorithm, than to tinker with code which nearly works. I was very brief about the 2 and -2, and you ought to have asked for more explanation rather than guessing what I meant. You can guess a million times, and your code looks as if you are guessing. Within those million you will find something which works. Or you can work it out, which means paper pencil and eraser (the latter being the most important). And get it right first time. And get elegant code.
When I say paper and pencil I mean paper and pencil. Turn your PC off. You can turn it on when you have worked out the algorithm and see it work



So I mean I don't really understand what you mean by starting at index 2. I mean I could set the counter to 2 and that way the first index would be the second index, but then I would have to add to to iFibN in order for the for loop to work.
5 years ago
Haha, yes indeed.
At least this has been the least frustrating of my assignments for this class.
5 years ago
I certainly understand that there are better ways to program than some ways.
It goes back to a question that was answered in class "If it's eligible to me; the program should be fine right?"
(I didn't ask this, someone else did).

I totally understand that this isn't correct. But for the sake of taking a java class I'm more trying to get things done rather than frustrate myself on something that works already.
I've spent plenty of time slamming my head against my keyboard trying to just get things to work, when I do I'm terrified of changing it for one, not being certain that I totally understand what someone is telling me.
And for two, that it's a triumph for me at the moment just to get the output correct. I at least recognize when the code I write is complete garbage, I had an instance of this several weeks ago.

But I suppose you're correct, the more messy code is the harder it is to fix. I guess my code making sense to me wasn't really the correct answer. I didn't really think it was that hard to read, but I guess being the one that wrote it, it wouldn't be for me.

Java hasn't really been the easiest thing for me to understand. Like Trigonometry it's totally abstract, there's tons of different ways to write the code and have the output be correct. But many more ways to write it and have it be a complete mess.

Programming hasn't been the easiest thing for me to accomplish. Which is one of the reasons I'm no longer pursuing a degree in it. However I do need a programming class up to advanced. So Java and advanced java for a minor I would like to obtain.

I'm just frustrated, and getting help hasn't been the easiest thing to accomplish, and it's definitely unhelpful when people even sound like they're trying to be discouraging. It also doesn't help that even my teacher isn't a java programmer and English isn't his first language, it's certainly a challenge to understand what's going on when it's difficult for the person to explain the concepts. Anyway, end rant. I do appreciate all the help I've received, there have been some that have been an extraordinary help in my class.
5 years ago

Campbell Ritchie wrote: - 2 and start with index 2.


I'm assuming you mean something liiiiike.

Edit: I should also note that for the above code the array is initialized as: int[] Fib = new int[iFibN]

Also as you can see above I fixed the way it displays the array without using a string builder.

Campbell Ritchie wrote:Please tell us where you found that info, so we can avoid that site!.


Found it here: Bad Advice?
I don't know though, I may have misunderstand what exactly they were using or what the OP was actually asking.

Also, still having a problem with printing, the code is as above in the previous post with the try/catch statements. I'm assuming I should change the last return of the method to something else but I can't seem to figure out what it'll be.
5 years ago
I'm doing my best, but for only having been programming for three months I'm trying to do what I can.

Edit: Also, to add to this. I disagree that there's a wrong way or right way to program, my program isn't incorrect and still works. So saying that "learning something about programming" is subtracting two instead of adding two, is completely ludicrous.
5 years ago
I guess I should add that I can't figure out how to change the return objFib statement in order to get it to print the array.
5 years ago
New Problems. I've changed the program around a little bit, in order to incorporate all of the stuff I need to to satisfy all of the parts for the final project.

So I've included some exceptions and a bit of inheritance in order to complete the rest of the final assignment objectives.





When I run the Code I get the proper output however the Array.toString(fib) prints "null" which isn't what it's supposed to print obviously it's supposed to print the sequence. I'm assuming it's because of the try catch returning the objFib and it being null? I know I haven't really fixed the rest of the stuff, but I figured if the program works, why mess with it? >.<
5 years ago
Sorry about the cross post, but it seems I get better results if I post in both places.
As you can see the other thread sort of turned into me explaining how my formula works, instead of me getting any real answers.

Sooo.... moving right along.

I appreciate all of your guys help. I figured it out, by Using Arrays.toString(Fib); instead of using a StringBuilder, I couldn't seem to quite figure out how to get a StringBuilder to work.
When I googled it, it looked like I would set up an array as:
StringBuilder[] Fib = new StringBuilder[intFibN];

But couldn't seem to figure out if that was supposed to replace the array I'm already using or what or how to implement it.


5 years ago
I'm having some trouble with my program for the final project.

My assignment is to take a user input of how many digits of the fibonacci sequence they wish to display, and then....display them.
However when I first ran the code, it would throw an ArrayOutofBounds exception.

So say the user input 5, the system would print out the first three correctly but then give me the exception. Which I understand to be that it's calling reserved array spots that don't exist. I fixed the code by adding 2 to the user input which defines the array size, but I feel like there has to be a better way.



The reason for the formula being + 2 is because I've already got the first two digits so the next array slot to be filled should be Fib[2] but I'm sure you all gathered that.

Also, I'd like the output to be in JOptionPane format, but I can't seem to get it to work without having to click ok, for every single array slot, which is just a pain. Any thoughts?
5 years ago
Ok, so I think I've gotten it down to the very last step (I think, and hope lol), here's what I've gotten so far.





from what I'm gathering from the instructions as I re-read them. I should be using the first for loop to instantiate five objects of the savings class and five objects of the checking class. I've probably gone about it in an inefficient manner, but it's what I've got so far.

My last step is what's blocking me at the moment. I'm not quite sure how to access the toString() methods in each of the other classes to get them to run and display in the for loop. Can anyone assist me, I greatly appreciate it.

Also, if you read the instructions and notice something amiss, I'd greatly appreciate that too.
5 years ago

Campbell Ritchie wrote:Another problem about what Henry calls “colour by numbers” is that you don’t know when something would be better done otherwise. Because you are told to use protected fields, for example, you never learn how much better private fields would have been.



This is also true, however we do go over them in class.
But you're correct, not just for field modifiers. I understand that in inheritance you can't use private variables/methods in any class other than the class that it's called in. And for protected variables/methods you can't use them outside of the super/subclasses... etc.
I atleast understand some principles.

I kind of wish we'd have multiple little programs that would work up to the final weekly program, so as to drill home the principles used in each chapter.
5 years ago
That's exactly how I feel. I've never used constructors this way.

But I think I've figured it out.
However, the balance is now what I'm pondering, how it ties into the rest of the program.

Here you see I've set up my array of ten account objects and have instantiated new objects of each class and used their constructor in order to fill in the information as per the instructions.


So I've got my five Checking and five savings as per the assignment instructions. But now I'm supposed to work in the balance of 1000 - 10000, I'm not seeing where this is supposed to be input. The only constructor that asks for a balance is the Account class. Being that the Account class is the super and checking and savings are both subclasses, I thought perhaps I'd be able to input the balance directly into the constructors being that the constructor would have been inherited (so maybe that the constructors for savings/checking might have inherited the spot for balance into their own constructors), but this isn't the case.

I really kind of wish we could get more practice. We're able to do the "you do it" portions of the text book, but being that this is simply a "copy it out of the book" type of practice it doesn't really help me. There are vague descriptions that go along with it that I try to decipher, but don't usually get very far with them.
5 years ago

Enkita mody wrote:UseCodeTags (<---click)



Yea, sorry about that, I'm used to being on another forum and accidently used the incorrect tag for it. But I fixed it.
5 years ago