Question: Describe and correct the syntax and/or logic errors in the following snippets of code. Code below public static void main(String[] args) { int num =

Describe and correct the syntax and/or logic errors in the following snippets of code.

Code below

public static void main(String[] args) {

int num = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

for (int i = 0; i < num.length - 1; i++) {

System.out.println("The sum is " + (num(i) + num(i + 1)));

}

}

Replace this text with your solution.

Code below

ArrayList numbers = new ArrayList();

Replace this text with your solution.

Code below

public static void main(String[] args) {

int[] num = { 7, 2, 6, 4, 12, 6, 1, 8, 49, 3 };

int lowest = num[0];

int highest = num[0];

for (int i = 0; i < num.length; i++) {

if (num[i] < lowest) {

lowest = num[i];

} else {

highest = num[i];

}

}

}

Replace this text with your solution.

Code below

public static boolean doesArrayContain(int [] arr, int target) {

boolean found = false;

for (int i = 0; i < arr.length; ++i) {

if (arr[i] == target) {

found = true;

} else {

found = false;

}

}

return found;

}

Replace this text with your solution.

Code below

public static void main(String[] args) {

ArrayList coins = new ArrayList();

coins.add("quarter");

coins.add("dime");

coins.add("nickel");

coins.add("penny");

System.out.println("The coins are: ");

for (int i = coins.size() - 1; i > 1; i--) {

System.out.println(coins.get(i) + " ");

}

}

Replace this text with your solution.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!