-
programming homework
can someone help me put these codes into a program? I missed a couple of classes and I don't know where to begin, if someone could start me off.
1. for (int count = 0; count < nums.length; count++)
nums[count] = INITIAL;
2.for (int count = names.length - 1; count >= 0; count--)
System.out.println(names[count]);
3.for (int index = 0; index < flags.length; index++)
flags[index] = (index%2 == 0);
4.public static float sumArray (float[] nums)
{
float sum = 0;
for (int count = 0; count < nums.length; count++)
sum += nums[count];
return sum;
}
:confused:
-
You need to know what the program is supposed to do. Otherwise, it's just guessing. I can tell what each thing is doing:
1. Filling up an array called nums with the value of a constant called INITIAL
2. Printing to screen the contents of an array called names
3. Filling up an array with boolean values if index is even
4. A method that sums the elements of an array passed as the method's parameter.
Luck,
CJSL
-
much better would be for you to try to start creating the program yourself and then come back if you have a specific question regarding your code. Also, try to get up with your teacher so you can get caught up fast. Programming is like math: if you miss studying some of the basics, you'll never be able to understand the more advanced stuff.
This tutorial may be able to help you in your studies:
Sun Java Tutorial
Best of luck!