Justin Bodin

+ Follow
since Oct 21, 2009
Merit badge: grant badges
For More
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 Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Justin Bodin

Hey Bert,

I actually did not figure it out using the method that I was going about. I ended up rewritting the entire program with much more OO code and storing the info in an inventory, and it worked great. I still don't think I could tell you why this previous program wouldn't work for me! It got really cluttered and hard to understand I think.
14 years ago
Not to be difficult, but if I knew how to do that then I would probably be able to relate the simple problem that someone posted earlier to get the correct answer to my specific program.

My issue involves not knowing how to do something outside of the main method, so I just really don't know how to formulate an 'example problem' for you guys to help me out with.

14 years ago
Understandable, thanks for the tips sir.

So I edited the code a bit to try and make only the pertinent information appear.
I have tried adding such things as:

to the Speed subclass, but to no avail -- all I get to display is the old information from the Product class!!
14 years ago
Yeah it was a good example, but I still couldn't get it to work.

Is it possible to do with the array set up the way it is? It seems like no matter what I tried, I couldn't get the Top Speed: to show display, only the original attributes.
14 years ago
yyyeah I'm not quite getting it. I don't think I fully understand the use of the super keyword. I can't seem to relate the simple examples I'm learning from to how to make it work in this code.
Sorry to sound potentially idiotic, but I have to make use of super. inside of a new toString() method within the Speed subclass...or no?
14 years ago
Does that mean write another toString() method in the Speed subclass but adding the top speed?
14 years ago
Whoops, yes I am.

You know, if I was trying to add to that method to display the "Top Speed:" using the getTopSpeed method from the Speed subclass. But it doesn't let me, and wants me to create another getTopSpeed method in that same Product class.

I may be going about it completely wrong, though...
14 years ago

I basically don't understand how to add a new attribute to the String method right above where the Speed class is in the code. I'm trying to add top speed to that but it doesn't let me because the method is in a different class I guess?
14 years ago
So I have this assignment that I am working on and my "instructor" is nowhere to be found.
Basically an array in the program holds the name, part number, unit price, quantity, and inventory value (qty*unit price) of 5 objects.
It displays all of this info in alphabetical order and then given a total inventory value at the bottom.

For the assignment I am supposed to create a subclass of my product class which will add another element to the array (I am trying to add top speed.)
I don't know how to get the information added into the current array and my brain hurts from reading so much into it. At the bottom of the product.java file, I have created a "Speed" class which holds methods I think should help get the job done but I'm just not sure if I am headed in the correct direction.

Some help would be greatly appreciated.

Thank you

14 years ago
Thanks for the prompt replies guys, I really appreciate it.

14 years ago
So another question. This is my first time trying to user setter/getter methods and cannot figure out why I am getting "cannot find symbol" each time I try to use the set or get method from another class.
I don't know if it's a small error I am missing or an entire concept I am not grasping. I will paste the code. The program is supposed to get name, weekly pay, and weekly hours worked from user and store that info in the methods in "Payroll1" That file is compiling fine, but my EmpInfo.java is giving the errors I explained.

Thanks for any help you all can offer me.



The output will not be working correctly yet, as I am trying to figure that out as well.

Thanks again
14 years ago
Ah yes!

Thanks for your help again. And I did read that most of that thread, I just missed that post apparently.
14 years ago
I did actually try it before I posted that, and it skips right over the user input.
It does make sense that the while loop should read the call to Scanner each time...I'm obviously doing something incorrectly.

Also, wouldn't you receive an input match exception pretty commonly if you use integer arithmetic for money?

Thanks again, I'm more grateful than I can express.
14 years ago
Hey Campbell, thank you for the tips I really appreciate it.

But in the code you posted, at line 21 shouldn't there be an

otherwise, when the hourly wage, and hours worked are input, the loop will again SKIP the user's input and move on to asking for the weekly wage again?

That was one of the main problems with my code that I originally posted, If would have put that after looping back and asking for the next employee's name, the code would have at least been functional.

But yes, thank you for the tips. My instructor also agreed letting me know that using breaks are bad programming practice.

Oh, and I was unsure whether to use double or float so I read a bit about it. I some how understood that float executed more quickly, and was more suited for numbers with a small amount of decimal places (ie: 5.50) so I went with that.
14 years ago
So I have seen this type of program on these boards a couple of times, but none with this specific issue. I also read that you all don't prefer going back into old threads, that it's a better idea to start a new thread with my own issues, so here it is.

I'm attempting to modify a program which will take user input for name, hourly pay, and weekly hours and compute the weekly pay. There also needs to be a "stop" sentinel incorporated into the program as well as verifying that the weekly hours and pay are not negatives.

I have come to the conclusion that a while loop will suffice on looping back to the employee name each time the program completes, but I am having issues. (I have not yet begun ensuring that the other variables are positive.)

The issue I am having is that when the program computes the total and goes back to loop to ask for the next employee's name, it prints but doesn't pause for user input but rather goes and outputs ""Please enter the hourly pay rate of the employee: " " and waits. I just cannot seem to figure out why.

Thanks in advance for any help, I really do appreciate the time.

14 years ago