Professional Documents
Culture Documents
CSC 202
Homework 3
2. class Main {
3. public static void main(String[] args) {
4.
5. int[] num = {1, 2, 3, 4, 5};
6. int toFind = 3;
7. boolean found = false;
8.
9. for (int n : num) {
10. if (n == toFind) {
11. found = true;
12. break;
13. }
14. }
15.
16. if(found)
17. System.out.println(toFind + " is found.");
18. else
19. System.out.println(toFind + " is not found.");
20. }
21. }
import java.util.Scanner;