3 Replies - 1073 Views - Last Post: 09 April 2007 - 09:23 AM Rate Topic: -----

#1 Donnie16  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 09-April 07

Help with searching an array and displaying your search

Post icon  Posted 09 April 2007 - 08:06 AM

Help im new and a little confused :ph34r:
Is This A Good Question/Topic? 0
  • +

Replies To: Help with searching an array and displaying your search

#2 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1877
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

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.
Was This Post Helpful? 0
  • +
  • -

#3 Donnie16  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 09-April 07

Re: Help with searching an array and displaying your search

Post icon  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.
Was This Post Helpful? 0
  • +
  • -

#4 Programmist  Icon User is offline

  • CTO
  • member icon

Reputation: 252
  • View blog
  • Posts: 1,833
  • Joined: 02-January 06

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?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1