Reference no: EM131803736
Linear Search algorithm. Your program will ask the user to input 10 letters (e.g., e, c, z, x, k, m, o, a, d, f). The program will store these 10 letters into an array. Then the program will ask the user which letter the user wants to search for. If the letter is in the array, the program should return the position of the letter in the array. If the letter is NOT in the array, the message "Letter not found" should display. The user must press "E" to exit. and lastly its has to be a GUI.
import javax.swing.JOptionPane;
public class LetterSearchGUI {
public static int search(String[] arr, String key) {
int size = arr.length;
for (int i = 0; i < size; i++) {
if (key.equalsIgnoreCase(arr[i])) {
return i;
}
}
return -1;
}
public static void main(String a[]) {
do {
String[] input = new String[10];
for (int i = 0; i < 10; i++) {
input[i] = JOptionPane.showInputDialog("Enter the letter "
+ (i + 1) + ": ");
}
String searchKey = JOptionPane
.showInputDialog("Enter the letter the user wants to search for: ");
int pos = search(input, searchKey);
if (pos == -1) {
JOptionPane.showMessageDialog(null, "Letter not found");
} else {
JOptionPane.showMessageDialog(null, "Key " + searchKey
+ " found at index: " + pos);
}
// string for exit button
String s = JOptionPane
.showInputDialog("Press E to exit the program or anything to continue: ");
if ("E".equalsIgnoreCase(s)) {
break;
}
} while (true);
}
}
What are the brief facts of case that led to investigation
: What are the brief facts of the case that led to the investigation
|
Discuss the value of simulation training-development
: Discuss the value of simulation training/development. How do we as HRM professionals objectively determine the "value" of simulation training?
|
Describe categories of consumer decision-making behavior
: Describe the three categories of consumer decision-making behavior. Name typical products for which each type of consumer behavior is used.
|
Which staffing strategy would you choosen
: Imagine a European MNC having to staff one of its subsidiaries that acts as a regional HQ for the Asian market.
|
Determining the linear search algorithm
: Linear Search algorithm. Your program will ask the user to input 10 letters (e.g., e, c, z, x, k, m, o, a, d, f).
|
What challenges are faced by corporations
: What challenges are faced by corporations in reducing the barriers to a healthy diet faced by those consumers of lower SES?
|
Prepare a review of the article and include the abstract
: prepare a review of the article, and include abstract from journal article. Your review should be succinctly written in a descriptive and informative manner.
|
Prepare a schedule of variable
: Prepare a schedule of variable, fixed, and total manufacturing costs for each account category
|
Who are the typical system stakeholders
: Who are the typical system stakeholders (the key players), and what are their unique roles?
|