I'm a newbie in Java and am currently learning Array List. If any of you will be so kind,I need to complete these basic exercises with for loops but I'm not sure how to set it up.
Programming Exercises for Chapter 46
Printable View
I'm a newbie in Java and am currently learning Array List. If any of you will be so kind,I need to complete these basic exercises with for loops but I'm not sure how to set it up.
Programming Exercises for Chapter 46
First things first. We aren't going to do your work for you. List out the exercises that you want help with, and we'll give you guidance.
I understand.
Then for the 1st exercise, this is what i got as of now, unsure of what to add in the for loop.
class Exercise1
{
public static void main ( String[] args )
{
int[] val = {0, 1, 2, 3};
for(int i;i<=3;i++)
{
val
}
sum = val
System.out.println( "Sum of all numbers = " + sum );
}
}
in your program code there are several things to look at..
you need to give the variable i an initial value
you need to declare what type of variable sum is and give it an initial value
the expression(formula) within your for loop for the running total i.e. sum = sum + val[i]