Copy the program and circle each error and write the correctprogram beside it. (5 errors)
This program code will check if an array of integers containstwo specified elements 65 and 77.
Program:
import java.util.*;
import java.io.*;
public class Exam32 {
public static void main(String[] args)
{
int[] array_nums = {77, 77, 65, 65, 65,77};
System.out.println("Original Array:"+Arrays.toString(array_nums));
int num1 = 77;
int num2 = 65;
System.out.println("Result:"+result(array_nums, num1, num2));
}
public static boolean result(int[] array_nums, intnum1, int num2) {
for (int number : array_nums) {
boolean r = number != num1&& number != num2;
if (r) {
returnfalse;
}
}
return true;
}
}
Output:
Original Array: [77, 77, 65, 65, 65,77]
Result: true. (ill upvote after)
Copy the program and circle each error and write the correct program beside it. (5 errors) This program code will check
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Copy the program and circle each error and write the correct program beside it. (5 errors) This program code will check
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!