I am not really sure what your question is. What exactly are you asking? Please read the link in my signature on asking questions the smart way and post an SSCCE with a specific question, and we'll go from there.

February 9th, 2012, 11:47 AM

Norm

Re: array size [10] need help!! any experts

When you have code that is repeated again and again and again with only a small consistent change from one to the next you should think about how to reduce the code to one instance by using a variable instead of hardcoding new numbers.
Look at the relationship between the value of i and the array index for these statements and the ones following it:

I am not really sure what your question is. What exactly are you asking? Please read the link in my signature on asking questions the smart way and post an SSCCE with a specific question, and we'll go from there.

sorry , is hard to type here if you have seen the program output. i am using methods for my java, as i am require to do an array size[10]

for my choice 1. i key in the calories for the day but my program can calculate up till 4 days when i exit. so i am asking how to use array to calculate up to 10 days when i press 3 exit.

so let say i key in 8 days in 1. Enter Food and Intake per day , my exit 3. should show 8 days of the calculated intake by using array

February 10th, 2012, 09:58 AM

asdin

Re: array size [10] need help!! any experts

Quote:

Originally Posted by Norm

When you have code that is repeated again and again and again with only a small consistent change from one to the next you should think about how to reduce the code to one instance by using a variable instead of hardcoding new numbers.
Look at the relationship between the value of i and the array index for these statements and the ones following it:

yeah i am figuring but i just cant do array really need help lol. for the question you ask. my index 1 represent my 1st selection choice in calories intake.

February 10th, 2012, 10:01 AM

Norm

Re: array size [10] need help!! any experts

Have you worked on the change I suggested to get rid of the 4 if statements and reduce the code to a few statements that uses an index that is computed from the value of i to access the contents of the array?
try something like this:

Have you worked on the change I suggested to get rid of the 4 if statements and reduce the code to a few statements that uses an index that is computed from the value of i to access the contents of the array?
try something like this:

yea, i am trying but i cant figure how to use method with arrays thats the problem... any ideas??? if i am not wrong i suppose to use array on my intergers values for breakfast,lunch,dinner. so it can store and loop back.

February 11th, 2012, 06:17 AM

Norm

Re: array size [10] need help!! any experts

Quote:

how to use method with arrays

Can you explain what data you are having problems using arrays with.
You are using an array here:
total = getdata[i-1];