* Array Search */ package int2200.week7; import java.util.Scanner; public class arraySearch { public static void main(String[] args) { } } // create and initializ an arry int[] numbers = {2, -9, 0, 5, 12, -25, 22, 9, 8, 12}; int key; boolean foundit = false; // declare a vraiable and initialize it to false Scanner input = new Scanner (System.in); // Create a Scanner object System.out.println("=>> Array Search program "); System.out.print("Enter a number to search for: "); key=input.nextInt (); // access all elements using for each loop for (int i=0; i< numbers.length; i++) { if (key == numbers [i]) { foundit=true; } } if (foundit == true){ System.out.println("found it! :)"); }else { System.out.println("Sorry } notfound it! :("); System.out.println("==> End of the Search Program "); /* =>> Array Search program Enter a number to search for: 2 found it! :) ==> End of the Search Program */

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter7: Using Methods
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question
/*
*
Array Search
package int2200.week7;
import java.util.Scanner;
*/
public class arraySearch {
public static void main(String[] args) {
// create and initializ an arry
int[] numbers = {2, -9, 0, 5, 12, -25, 22, 9, 8, 12};
int key;
}
}
boolean foundit = false; // declare a vraiable and initialize it to false
Scanner input = new Scanner (System.in); // Create a Scanner object
System.out.println("=>> Array Search program ");
System.out.print("Enter
a number to search for: ");
key=input.nextInt ();
// access all elements using for each loop
for (int i=0; i< numbers.length; i++) {
if (key == numbers [i]) {
foundit=true;
}
}
if (foundit == true){
System.out.println("found it! :)");
}else {
System.out.println("Sorry
}
System.out.println("==> End of the Search Program ");
/*
=>> Array Search program
Enter a number to search for: 2
found it! :)
notfound it! :(");
==> End of the Search Program
*/
Transcribed Image Text:/* * Array Search package int2200.week7; import java.util.Scanner; */ public class arraySearch { public static void main(String[] args) { // create and initializ an arry int[] numbers = {2, -9, 0, 5, 12, -25, 22, 9, 8, 12}; int key; } } boolean foundit = false; // declare a vraiable and initialize it to false Scanner input = new Scanner (System.in); // Create a Scanner object System.out.println("=>> Array Search program "); System.out.print("Enter a number to search for: "); key=input.nextInt (); // access all elements using for each loop for (int i=0; i< numbers.length; i++) { if (key == numbers [i]) { foundit=true; } } if (foundit == true){ System.out.println("found it! :)"); }else { System.out.println("Sorry } System.out.println("==> End of the Search Program "); /* =>> Array Search program Enter a number to search for: 2 found it! :) notfound it! :("); ==> End of the Search Program */
Modify the following java program to have the flowing output:
Provide:
Documentation and exact output
Hint: needs a do-while!
==>> Array Search program
Enter a number to search for: 2
found it! :)
Enter any number to continue or number 0 to exit: 5
=>> Array Search program
Enter a number to search for: 6
Sorry not found it! :(
Enter any number to continue or number 0 to exit: 0
==> End of the Search Program!
Transcribed Image Text:Modify the following java program to have the flowing output: Provide: Documentation and exact output Hint: needs a do-while! ==>> Array Search program Enter a number to search for: 2 found it! :) Enter any number to continue or number 0 to exit: 5 =>> Array Search program Enter a number to search for: 6 Sorry not found it! :( Enter any number to continue or number 0 to exit: 0 ==> End of the Search Program!
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,