hI, i'm trying to have this method take in an array and have it look for anything over 8 hours in the array. I have an If else to look for any amount over 8. and to put into a new array...
does anyone see any problem with this...
public static int overTimeDetermin(int otArray)
int otCalcArray = new int;
for(i=1; i<7; i++)
otCalcArray[i] = 0;
what's going on here:
Arrays are 0 based so the first term should be i = 0;
Your second term 1 > 8 makes no sense. One will never be greater than 8. usually here we try to make sure that i traverses the entire array, no more, no less, and so we use the array's own data to tell us when to stop: i < otCalcArray.length;
i think you have a logic issue in your method. As it stands your if clause says, if the value of otArray[i] is less than 8, otCalcArray[i]=(otArray[i]-8) so you will be sticking negative numbers in the array. Additionally, do you plan on calculating an int value to return? if you intend to return the otCalcArray the method declaration will need to change.
As always, if you are getting compile errors it is best to post the entire error message as that will make it easiest to diagnose the problem.
it's wise not to edit your original post, or if you do, note what you edited. someone who doesn't notice might think anyone commenting about what you edit out is crazy or stupid.
anyways, what error do you get? do you know what it means? it'd be nice to see what you know and have tried.
I think you should care of arrays indexing. If you have forget those things, it's better to refer some materials about arrays as well. Because you are using index in wrong way.
And also as emceenugget says, don't edit the original post. If you comes with something new post them in a new post.
Once you get an error, please copy-paste the full error message to see others. It's really helpful to answering.
IF this is your whole message body then its not compiling as its not returning an int as expected.
I think the logic is wrong. If you're looking for overtime, shouldn't the if comparation be:
Because otnerwise you'll be putting negatives numbers in array otCalcArray.
wow, so as many of you may have noticed after I posted that i found a lot of little errors some people pointed out. Thanks for your help!
Actually lots of members are here ready to help you. Most important thing is you must explain the question more clearly :)
If you have solve the problem please mark the thread as solved.