3 Replies - 933 Views - Last Post: 09 April 2007 - 09:23 AM
#1
Help with searching an array and displaying your search
Posted 09 April 2007 - 08:06 AM
Help im new and a little confused
Replies To: Help with searching an array and displaying your search
#2
Re: Help with searching an array and displaying your search
Posted 09 April 2007 - 08:11 AM
Donnie, welcome to dream.in.code.
We do have a policy by which we like to see a good faith effort before providing assistance. Could you show us the code you have so far. We'll also need some more information about your problem.
We do have a policy by which we like to see a good faith effort before providing assistance. Could you show us the code you have so far. We'll also need some more information about your problem.
#3
Re: Help with searching an array and displaying your search
Posted 09 April 2007 - 08:17 AM
/*
* Main.java
*
* Created on April 2, 2007, 9:09 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package javaapplication21;
import java.awt.*;
import javax.swing.*;
import java.io.*;
/**
*
* @author dseech
*/
public class Main {
/** Creates a new instance of Main */
public Main() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String favoritePerson;
String exit;
String doAgain;
String person;
String actor;
String actress;
String search;
boolean repeat=true;
do{
repeat = false;
favoritePerson = JOptionPane.showInputDialog("How do you want to answer who your favorite person is?"+'\n'+"1. Friend/Family"+'\n'+"2. Actor"+'\n'+"3. Actress"+'\n'+"4. Search"+'\n'+"5. Exit");
int id = Integer.parseInt(favoritePerson);
switch(id){
case 1:
person = JOptionPane.showInputDialog("Who is your favorite friend/family member?");
System.out.println("person " + person);
JOptionPane.showMessageDialog(null, "That's a good choice!");
doAgain=JOptionPane.showInputDialog("Do You want to quit or start again?" +'\n'+ "Start again or Quit?");
if(doAgain.equals("yes") || doAgain.equals("yes"))
{
repeat=true;
}
else
{
JOptionPane.showMessageDialog(null,"Good Bye");
repeat=false;
}
break;
case 2:
actor = JOptionPane.showInputDialog("Who is your favorite actor?");
System.out.println("actor " + actor);
JOptionPane.showMessageDialog(null, "That's a good choice!");
doAgain=JOptionPane.showInputDialog("Do You want to quit or start again?" +'\n'+ "Start again or Quit?");
if(doAgain.equals("yes") || doAgain.equals("yes"))
{
repeat=true;
}
else
{
JOptionPane.showMessageDialog(null,"Good Bye");
repeat=false;
}
break;
case 3:
actress = JOptionPane.showInputDialog("Who is your favorite actress?");
System.out.println("actress " + actress);
JOptionPane.showMessageDialog(null, "That's a good choice!");
doAgain=JOptionPane.showInputDialog("Do You want to quit or start again?" +'\n'+ "Start again or Quit?");
if(doAgain.equals("yes") || doAgain.equals("yes"))
{
repeat=true;
}
else
{
JOptionPane.showMessageDialog(null,"Good Bye");
repeat=false;
}
break;
case 4:
JOptionPane.showInputDialog("Who do you want to search for?");
doAgain=JOptionPane.showInputDialog("Do You want to quit or start again?" +'\n'+ "Start again or Quit?");
if(doAgain.equals("yes") || doAgain.equals("yes"))
{
repeat=true;
}
else
{
JOptionPane.showMessageDialog(null,"Good Bye");
repeat=false;
}
break;
case 5:
JOptionPane.showMessageDialog(null,"Please come again");
doAgain=JOptionPane.showInputDialog("Do You want to quit or start again?" +'\n'+ "Start again or Quit?");
if(doAgain.equals("yes") || doAgain.equals("yes"))
{
repeat=true;
}
else
{
JOptionPane.showMessageDialog(null,"Good Bye");
repeat=false;
}
break;
default:
JOptionPane.showMessageDialog(null,"You have choosen an invalid menu item, Or you entered an unknown name"+'\n'+"Please choose a valid menu item.");
repeat=true;
}
}while(repeat);
}
}
i know how to make an array i just don't know how to search it.
#4
Re: Help with searching an array and displaying your search
Posted 09 April 2007 - 09:23 AM
I have two questions.
1. Is your data sorted?
2. Are you allowed to use Java libraries to search the array, or do you have to implement your own search algorithm?
1. Is your data sorted?
2. Are you allowed to use Java libraries to search the array, or do you have to implement your own search algorithm?
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|