Reference no: EM131802157
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 was the amortization expense amount per month
: Chamber Company purchased a truck on January 1 20A, at a cash cost of $10,600. What was the amortization expense amount per month
|
Structured analysis-design
: Who are the typical system stakeholders (the key players), and what are their unique roles?
|
Advocates of shareholder capitalism tend
: Advocates of shareholder capitalism tend to do all of the following EXCEPT:
|
Discuss the features of cognitive learning
: List and discuss three features of cognitive learning. Write a minimum of 3 sentences about each feature.
|
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.
|
Prepare the journal entry to record the acquisition
: Land $22,500, Building $58,500, and Fixtures $9,000. Prepare the journal entry to record the acquisition. Show your work
|
What do you think about the whole situation
: What do you think about the whole situation. Develop a proper quantitative analysis
|
Write clearly and persuasively using proper grammar
: Write clearly, coherently, and persuasively using proper grammar, mechanics, and formatting appropriate to the situation.
|
Describe the importance of vba
: What is VBA? Why do we need VBA, in two lengthy paragraph describe the importance of VBA
|