Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 12 of 12

Thread: Phone Directory program

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Phone Directory program

    Hi

    I have project in Data Structures

    this is the question



    and this is 4 class for the program

    main class

    PHP Code:
     //-------------------------------------------------------------------------------------Backages
    import java.util.*;
    import java.util.Scanner;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;

    //--------------------------------------------------------------------------------------Class Main
    public class Main extends JFrame 
    {
             final 
    Users theUser = new Users();
              
    //------------------------------------------------------------------------------------1--Method main  
    public static void main(String[] args)
      { 
            new 
    Main().setVisible(true);//call method Main   
      
    }//end public static void main

    //-----------------------------------------------------------------------------------2--Mathod Main
      
    public Main() 
      {
             
    theUser.Users();
             
    //------------------
             
    setTitle("Phone Directory");
             
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //---------------------------------------------------------------------------Date-Photo-size-color
             
    Date da = new Date();
             
    Container contentPane getContentPane();
             
    contentPane.setLayout(new BorderLayout());
             
    contentPane.setBackground(Color.green);
             
    setSize(300,300);
             
    //-------------------
             
    JLabel time = new JLabel("          Today is : " +da);
           
    getContentPane().add(time);
             
    //----------------
            
    setResizable(false);        
             
    setLocationRelativeTo(null);     
             
    String imgStr1 "c://EQLS.png";
             
    ImageIcon image = new ImageIcon(imgStr1);     
             
    JLabel label1 = new JLabel(" "imageJLabel.CENTER);
             
    getContentPane().add(label1);
             
    validate();    
             
    setVisible(true); 
    //-----------------------------------------------------------------------------------------Button1
        
    JButton button1 = new JButton("*~...~*  Welcome *~...~*");
        
        
    button1.addActionListener(new ActionListener() {   public void actionPerformed(ActionEvent e
          {
              
    JOptionPane.showMessageDialog((Componente.getSource(), "\n\nThe main idea behind my system is\n\n\n to make the search for teacher information easier using a computer system.\n\n");
            }
        });
    //end button1
        
    //-----------------------------------------------------------------------------------------Button2
        
    JButton button2 = new JButton("Main User Access: Phone Directory");
        
    button2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e)
          { 
             
    String Option1 JOptionPane.showInputDialog(null,"Please Enter The Number of Choice !? \n1) View list ROOM\n2) SEARCH THE DATA OFTEACHER\n3) Remove DATA OF TEACHER list\n4) Delete\n5) Return\n6) Exit\n""Phone Directory Options"JOptionPane.INFORMATION_MESSAGE);
             
    int ConvOption1 Integer.parseInt(Option1);
             
    theUser.mainUser(ConvOption1,Option1);//go to main User method
          
    }//end method public void actionListener       String Option1 = JOptionPane.showInputDialog(
        
    });//end button2
        
    //-----------------------------------------------------------------------------------------Button3         
        
    JButton button3= new JButton("Exit");
        
    button3.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
          {
            
    int result JOptionPane.showConfirmDialog((Componente.getSource(),"Close Phone Directory SYSTEM");
            if (
    result == JOptionPane.YES_OPTION)
            {
    System.exit(0);} 
          }
        });
    //end button3
    //------------------------------------------------------------------------------------------
      //  setLayout(new FlowLayout(FlowLayout.CENTER));
        
    setLayout(new GridLayout(8,4));
        
    getContentPane().add(button1);
        
       
    getContentPane().add(button2);
        
        
    getContentPane().add(button3);
        
      }
    //end public method Main
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    }//end class Main 

    Users class

    PHP Code:
    import javax.swing.JFrame
    import java.util.Scanner;
    import javax.swing.JOptionPane;

    class 
    Users

         
    linkList theList = new linkList();
         
    Scanner input = new Scanner(System.in);
          
           
    int a 0
           
    int b 0;       
           
    int key,r;
           
    Link v,df;
           
    public 
    void Users()
    {    

    JOptionPane.showMessageDialog (null"   *~...~*  WELCOME *~...~*\n\n  PHONE DIRECTORY SYSTEM\n\n    For Login Please Click Ok\n\n"" {ELECTRONIC SYSTEM OF PHONE DIRECTORY]"JOptionPane.INFORMATION_MESSAGE);
     
    JFrame frame = new JFrame();

            
    int SENTINEL 123//password number
            
    String str;  //password number which the user will Enter it
            
    int password 0;
            
    int counter 5;
            
                  
    while (
    counter != && password != SENTINEL)
           {     
            
    str JOptionPane.showInputDialog("Enter Password");
           
            
    password Integer.parseInt(str);
              
            if(
    password == SENTINEL)
            {
                
    JOptionPane.showMessageDialog(null"CORRECT");
                
    System.out.println("\n\t*~...~* The Messages of PHONE DIRECTORY SYSTEM *~...~*\n\n-------------------------------------------------------------------------- \n");        
            }
            else if(
    password!=SENTINEL)
            {
                 
    JOptionPane.showMessageDialog(null"Wrong try again");
            }
            
    counter counter-1;
           
            if (
    counter == 0)
            {
                
    JOptionPane.showMessageDialog(null"Acces Denied!!! \nPlease contact Helpdesk");      
                
    System.exit(0);
            }
           }
               
    String backupDir="" ;
           
                    
    theList.insertFirst(16"08120014""Ms. Fahmeeda Aziz","043258088");
                    
    theList.insertFirst(15"08120014""Dr. Farhana Shaheen ","043258088");
                    
    theList.insertFirst(14"08120014""Dr. Fatima Al-Zwaihri ""043258088");
                    
    theList.insertFirst(13"08120014""Dr. Tahani Sindi    ""043258088"); 
                    
    theList.insertFirst(12"08120014""Dr. Nagla Osman     ""043935024"); 
                    
    theList.insertFirst(11"08120014""Ms. Atiya Azmi      ""043258088"); 
                    
    theList.insertFirst(10"08120014""Ms. Aisha Al-Johani   ""043258088");
                    
    theList.insertFirst(9"08120014""Ms. Siti Haryani Mohd ""043935024"); 
                    
    theList.insertFirst(8,"08120014""Ms.Humera Ghani     ""043258088");
                    
    theList.insertFirst(7"08120014""Ms. Salma Sadiqha    ""043258088");
                    
    theList.insertFirst(6"08120014""Ms. Azra Sultana     ""043935024"); 
                    
    theList.insertFirst(5"08120014""Ms. Ruchi Tuli     ""043258088");
                    
    theList.insertFirst(4"08120014""Ms. Fozia Noor   ""043258088");
                    
    theList.insertFirst(3"08120014""Ms. Kajal nusratullah  ""043258088");
                    
    theList.insertFirst(2"08120014""Ms.Anusuyah Subbarao  ""043935024");
                    
    theList.insertFirst(1"08120014""Ms. Aizal Yusrina ""043258088");
    }

    public 
    void mainUser(int ConvOption1,String Option1)
    {
    while(
    ConvOption1!=6)
        {
           switch (
    ConvOption1// 5 cases
           
    {
           case 
    1: {
                   
    theList.displayList();
                   
    System.out.println("---------------------------------------------------------------------------\n");
                  }
           break;
           
           case 
    2: {
               
               
    //  Option1 = JOptionPane.showInputDialog("Enter how MANY TEACHERS U WANT TO FIND");
          //        a = Integer.parseInt(Option1);
                        
        
    System.out.println("Enter how MANY TEACHERS U WANT TO FIND");
                
    a=input.nextInt();
                   
                  
    //theList. display1() ;
                   
    for(int j=1;j<=a;j++)
                   {
                       
               
    //        Option1 = JOptionPane.showInputDialog("\nEnter Number of Teacher Room    "+j+"  ");
               //     b = Integer.parseInt(Option1);
                      
                 
    System.out.println("\nEnter Number of Teacher Room    "+j+"  ");
                   
    b=input.nextInt();
                    
                   
    theList.findb); 
                            
    // find item
                   
    if( != null)
                   {
                   
                
    System.out.println("\nTEACHER NAME IS: "+f.Teacher_Name+"\nTEACHER ID: "+f.teacher_ID+"\nPHONE NUMBER IS: "+f.Phone_number);
                   
                 
    //  JOptionPane.showMessageDialog(null,"\nTEACHER NAME IS: "+f.Items+"\nTEACHER ID: "+f.qui+"\nPHONE NUMBER IS: "+f.price);
                     
                    // System.out.println("\nQuintity of "+f.Items+" Now is "+e);
                     
                     
    }
                   else
                   {
                   
    System.out.println("we did FOUND "+f.Teacher_Name);  
                    } 
                    }
                   
                  
    // System.out.println("\n  price ="+t);
                    
                  
    System.out.println("---------------------------------------------------------------------------\n");
                }
          break;
          
          case 
    3: {
              
              
    System.out.println("Enter THE ROOM NUMBER OF TEACHER  ");
              
    int key=input.nextInt();
              
    Link i theList.delete(key);        // delete item
              
    if( != null )
              {
              
               
    System.out.println("Deleted NUMBER OF ROOM : "+  i.Room_Number+"\n");
               
    System.out.println("Delet the ID :  "+i.teacher_ID +"\n");
               
    System.out.println("Delet the Name Of TEACHER : "i.Teacher_Name+"\n" );
               
    System.out.println("Delet the PHONE NUMBER :  "+i.Phone_number+"\n");
              
              
              
    System.out.println("SUCCESSFUL DELET");
              } 
              else
              {
              
              
    System.out.println("Can't delete ");
              
              
    System.out.println("the data still in list "+i);
              }
              
    System.out.print("---------------------------------------------------------------------------\n");
                 } 
              break;
           
           case 
    4: {
                  
    theList.display2();
                  
    System.out.println("Enter ROOM NUMBER:>");
                  
    keyinput.nextInt();
                  
    Link i theList.delete(key);  
                  
    System.out.print("---------------------------------------------------------------------------");
                  
                  
    System.out.println("\nlist after EDIT:>");
                  
    theList.display2();
                  
    System.out.println("---------------------------------------------------------------------------\n");
                 }
            break;
              
       }
    //end switch
       
        
    if(ConvOption1>6)
        {
        
         
    JOptionPane.showMessageDialog(null"YOUAR INPUT NUMBER NOT IN THE LIST\n              PLEASE, TRY AGAIN");       
        }
         
    Option1 JOptionPane.showInputDialog("\n1-Show List of TEACHERS\n2-SEARCH \n3-Remove \n4-Borrow\n5-Return\n6-Exit");
         
    ConvOption1 Integer.parseInt(Option1);
        }
    //end while
       
    }
    }
    //end mainUser method 

    Link class

    PHP Code:
     class Link 
      

        public 
    int Room_Number
        public 
    String teacher_ID
        public 
    String Teacher_Name
        public 
    String Phone_number// data item 
        
    public Link next// next link in list 

        // ------------------------------------------------------------- 

        
    public Link(int aString bString teacherString Phone// constructor 
        

            
    Room_Number a
            
    teacher_ID b// constructor 
            
    Teacher_Name teacher
            
    Phone_number Phone

        } 
    // set to null) 
            // ------------------------------------------------------------- 

        
    public void displayLink1() 
        
    // display ourself 
        


            
    System.out.println("\t" Teacher_Name "\t\t{" Room_Number "}"); 
            
    System.out.println(""); 
        } 


        public 
    void displayLink2() 
        
    // display ourself 
        

            
    System.out.print("\t" Room_Number); 
            
    System.out.print("\t" teacher_ID); 
            
    System.out.print("\t" Teacher_Name); 
            
    System.out.println("\t\t{" Phone_number "}"); 
        }


    linkList class

    PHP Code:
    class linkList
     

        private 
    Link first// ref to first link on list 

        // ------------------------------------------------------------- 
        
    public linkList() // constructor 
        

            
    first null// no links on list yet 
        


        
    // ------------------------------------------------------------- 
        
    public boolean isEmpty() // true if list is empty 
        

            return (
    first == null); 
        } 
        
    // ------------------------------------------------------------- 
        // insert at start of list 
            
    public String insertFirst(int aString SDString teacherString Phone) { // make 
                                                                            // new 
                                                                            // link 
            
    Link newLink = new Link(aSDteacherPhone); 
            
    newLink.next first// newLink --> old first 
            
    first newLink// first --> newLink 
            
    return first.Room_Number "  " first.teacher_ID "  " first.Teacher_Name "{" first.Phone_number "}"
        } 

        
    // ------------------------------------------------------------- 
        
    public Link find(int key// find link with given key 
        
    // (assumes non-empty list) 
            
    Link current first// start at 'first' 
            
    while (current.Room_Number != key// while no match, 
            

                if (
    current.next == null// if end of list, 
                    
    return null// didn't find it 
                
    else 
                    
    // not end of list, 
                    
    current current.next// go to next link 
            

            return 
    current// found it 
        


        
    // ///////////////////////////////////// 
        
    public Link delete(int key// delete link with given key 
        
    // (assumes non-empty list) 
            
    Link current first// search for link 
            
    Link previous first
            while (
    current.Room_Number != key) { 
                if (
    current.next == null
                    return 
    null// didn't find it 
                
    else { 
                    
    previous current// go to next link 
                    
    current current.next
                } 
            } 
    // found it 
            
    if (current == first// if first link, 
                
    first first.next// change first 
            
    else 
                
    // otherwise, 
                
    previous.next current.next// bypass it 
            
    return current
        } 

        
    // ------------------------------------------------------------- 

        
    public void displayList() { 
            
    System.out.println("\t\t\n\n                        *~...~*  Welcome *~...~*\n\n "); 
            
    System.out.print("\n\n\t\t               The Menue  \n\n"); 
            
    System.out.println("\n\t :: NAME OF TEACHERS ::\t\t:: NUMBER OF ROOM ::"); 
            
    System.out.println(""); 
            
    Link current first// start at beginning of list 
            
    while (current != null// until end of list, 
            

                
    current.displayLink1(); // print data 
                
    current current.next
                
    // move to next link 
            

            
    System.out.println(""); 
        } 

        public 
    void display2() { 
            
    System.out.print("\t\t        *~...~*  The Menue *~...~*  \n\n"); 
            
    System.out.println("\n\tR.N.    ID              TEACHER NAME \t                PHONE NUMBER\n "); 
            
    Link current first// start at beginning of list 
            
    while (current != null// until end of list, 
            

                
    current.displayLink2(); // print data 
                
    current current.next
                
    // move to next link 
            

            
    System.out.println(""); 
        } 
        
    // ------------------------------------------------------------- 
    // end class LinkList 


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,613
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: Phone Directory program

    Do you have any specific questions about your assignment?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Phone Directory program

    Yes

    I used in this program Doubly Linked List

    and this is the out put



    I want ues insert method

    so the user can add teacher name, Id,Phone number and teacher room in to current list

    how can I do this

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,613
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: Phone Directory program

    I want ues insert method
    Is the insert() method defined yet? I don't see it in the code.
    How is that method supposed to work? What args does it take and what does it return?


    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Phone Directory program

    Yes My question is

    This method

    PHP Code:
    public boolean insertAfter(double keydouble dd)

    Link current first
    while(
    current.dData != key)    // until match is found
         
    {
      
    current current.next;     // move to next link
      
    if(current == null)
    return 
    false;         // didn't find it
         
    }
    Link newLink = new Link(dd);     
    if(
    current==last)         
         {
      
    newLink.next null;     // newLink --> null
      
    last newLink;         // newLink <-- last
         
    }
         else
         {
      
    newLink.next current.next;     // newLink --> old next
      
    current.next.previous newLink;     // newLink <-- old next
         
    }
    newLink.previous current;     // old current <-- newLink
    current.next newLink;     // old current --> newLink
    return true;         // insert


    How I can connect it with my program

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,613
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: Phone Directory program

    How I can connect it with my program
    You have to put the code into the program to be able to use it.
    What class does it go in? Have you tried using the editor to copy and paste that code into the source for the class that you want it in?
    Then compile it.
    When there are no compiler errors, then code some uses of the method to see if it works correctly. Print out the list before the insert and after the insert to see if it worked correctly.


    The code needs to be properly formatted. The indentations of the statements is wrong. Nested statements should be indented 3-4 spaces.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Dec 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Phone Directory program

    I tries and I have add insertlist method BUT it have some errors .. could you plz hepl my to find what are the errors ....
    those are the cods after adding the method // ??

    main class

    PHP Code:
     //-------------------------------------------------------------------------------------Backages
    import java.util.*;
    import java.util.Scanner;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;

    //--------------------------------------------------------------------------------------Class Main
    public class Main extends JFrame 
    {
             final 
    Users theUser = new Users();
              
    //------------------------------------------------------------------------------------1--Method main  
    public static void main(String[] args)
      { 
            new 
    Main().setVisible(true);//call method Main   
      
    }//end public static void main

    //-----------------------------------------------------------------------------------2--Mathod Main
      
    public Main() 
      {
             
    theUser.Users();
             
    //------------------
             
    setTitle("Phone Directory");
             
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //---------------------------------------------------------------------------Date-Photo-size-color
             
    Date da = new Date();
             
    Container contentPane getContentPane();
             
    contentPane.setLayout(new BorderLayout());
             
    contentPane.setBackground(Color.green);
             
    setSize(300,300);
             
    //-------------------
             
    JLabel time = new JLabel("          Today is : " +da);
           
    getContentPane().add(time);
             
    //----------------
            
    setResizable(false);        
             
    setLocationRelativeTo(null);     
             
    String imgStr1 "c://EQLS.png";
             
    ImageIcon image = new ImageIcon(imgStr1);     
             
    JLabel label1 = new JLabel(" "imageJLabel.CENTER);
             
    getContentPane().add(label1);
             
    validate();    
             
    setVisible(true); 
    //-----------------------------------------------------------------------------------------Button1
        
    JButton button1 = new JButton("*~...~*  Welcome *~...~*");
        
        
    button1.addActionListener(new ActionListener() {   public void actionPerformed(ActionEvent e
          {
              
    JOptionPane.showMessageDialog((Componente.getSource(), "\n\nThe main idea behind my system is\n\n\n to make the search for teacher information easier using a computer system.\n\n");
            }
        });
    //end button1
        
    //-----------------------------------------------------------------------------------------Button2
        
    JButton button2 = new JButton("Main User Access: Phone Directory");
        
    button2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e)
          { 
             
    String Option1 JOptionPane.showInputDialog(null,"Please Enter The Number of Choice !? \n1) View list ROOM\n2) SEARCH THE DATA OFTEACHER\n3) Remove DATA OF TEACHER list\n4) Delete\n5) Return\n6) Exit\n""Phone Directory Options"JOptionPane.INFORMATION_MESSAGE);
             
    int ConvOption1 Integer.parseInt(Option1);
             
    theUser.mainUser(ConvOption1,Option1);//go to main User method
          
    }//end method public void actionListener       String Option1 = JOptionPane.showInputDialog(
        
    });//end button2
        
    //-----------------------------------------------------------------------------------------Button3         
        
    JButton button3= new JButton("Exit");
        
    button3.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e)
          {
            
    int result JOptionPane.showConfirmDialog((Componente.getSource(),"Close Phone Directory SYSTEM");
            if (
    result == JOptionPane.YES_OPTION)
            {
    System.exit(0);} 
          }
        });
    //end button3
    //------------------------------------------------------------------------------------------
      //  setLayout(new FlowLayout(FlowLayout.CENTER));
        
    setLayout(new GridLayout(8,4));
        
    getContentPane().add(button1);
        
       
    getContentPane().add(button2);
        
        
    getContentPane().add(button3);
        
      }
    //end public method Main
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    }//end class Main 
    users class

    PHP Code:
    import javax.swing.JFrame
    import java.util.Scanner;
    import javax.swing.JOptionPane;

    class 
    Users

         
    linkList theList = new linkList();
         
    Scanner input = new Scanner(System.in);
          
           
    int a 0
           
    int b 0;       
           
    int key,r;
           
    Link v,df;
           
    public 
    void Users()
    {    

    JOptionPane.showMessageDialog (null"   *~...~*  WELCOME *~...~*\n\n  PHONE DIRECTORY SYSTEM\n\n    For Login Please Click Ok\n\n"" {ELECTRONIC SYSTEM OF PHONE DIRECTORY]"JOptionPane.INFORMATION_MESSAGE);
     
    JFrame frame = new JFrame();

            
    int SENTINEL 123//password number
            
    String str;  //password number which the user will Enter it
            
    int password 0;
            
    int counter 5;
            
                  
    while (
    counter != && password != SENTINEL)
           {     
            
    str JOptionPane.showInputDialog("Enter Password");
           
            
    password Integer.parseInt(str);
              
            if(
    password == SENTINEL)
            {
                
    JOptionPane.showMessageDialog(null"CORRECT");
                
    System.out.println("\n\t*~...~* The Messages of PHONE DIRECTORY SYSTEM *~...~*\n\n-------------------------------------------------------------------------- \n");        
            }
            else if(
    password!=SENTINEL)
            {
                 
    JOptionPane.showMessageDialog(null"Wrong try again");
            }
            
    counter counter-1;
           
            if (
    counter == 0)
            {
                
    JOptionPane.showMessageDialog(null"Acces Denied!!! \nPlease contact Helpdesk");      
                
    System.exit(0);
            }
           }
               
    String backupDir="" ;
           
                    
    theList.insertFirst(16"08120014""Ms. Fahmeeda Aziz","043258088");
                    
    theList.insertFirst(15"08120014""Dr. Farhana Shaheen ","043258088");
                    
    theList.insertFirst(14"08120014""Dr. Fatima Al-Zwaihri ""043258088");
                    
    theList.insertFirst(13"08120014""Dr. Tahani Sindi    ""043258088"); 
                    
    theList.insertFirst(12"08120014""Dr. Nagla Osman     ""043935024"); 
                    
    theList.insertFirst(11"08120014""Ms. Atiya Azmi      ""043258088"); 
                    
    theList.insertFirst(10"08120014""Ms. Aisha Al-Johani   ""043258088");
                    
    theList.insertFirst(9"08120014""Ms. Siti Haryani Mohd ""043935024"); 
                    
    theList.insertFirst(8,"08120014""Ms.Humera Ghani     ""043258088");
                    
    theList.insertFirst(7"08120014""Ms. Salma Sadiqha    ""043258088");
                    
    theList.insertFirst(6"08120014""Ms. Azra Sultana     ""043935024"); 
                    
    theList.insertFirst(5"08120014""Ms. Ruchi Tuli     ""043258088");
                    
    theList.insertFirst(4"08120014""Ms. Fozia Noor   ""043258088");
                    
    theList.insertFirst(3"08120014""Ms. Kajal nusratullah  ""043258088");
                    
    theList.insertFirst(2"08120014""Ms.Anusuyah Subbarao  ""043935024");
                    
    theList.insertFirst(1"08120014""Ms. Aizal Yusrina ""043258088");
    }

    public 
    void mainUser(int ConvOption1,String Option1)
    {
    while(
    ConvOption1!=6)
        {
           switch (
    ConvOption1// 5 cases
           
    {
           case 
    1: {
                   
    theList.displayList();
                   
    System.out.println("---------------------------------------------------------------------------\n");
                  }
           break;
           
           case 
    2: {
               
               
    //  Option1 = JOptionPane.showInputDialog("Enter how MANY TEACHERS U WANT TO FIND");
          //        a = Integer.parseInt(Option1);
                        
        
    System.out.println("Enter how MANY TEACHERS U WANT TO FIND");
                
    a=input.nextInt();
                   
                  
    //theList. display1() ;
                   
    for(int j=1;j<=a;j++)
                   {
                       
               
    //        Option1 = JOptionPane.showInputDialog("\nEnter Number of Teacher Room    "+j+"  ");
               //     b = Integer.parseInt(Option1);
                      
                 
    System.out.println("\nEnter Number of Teacher Room    "+j+"  ");
                   
    b=input.nextInt();
                    
                   
    theList.findb); 
                            
    // find item
                   
    if( != null)
                   {
                   
                
    System.out.println("\nTEACHER NAME IS: "+f.Teacher_Name+"\nTEACHER ID: "+f.teacher_ID+"\nPHONE NUMBER IS: "+f.Phone_number);
                   
                 
    //  JOptionPane.showMessageDialog(null,"\nTEACHER NAME IS: "+f.Items+"\nTEACHER ID: "+f.qui+"\nPHONE NUMBER IS: "+f.price);
                     
                    // System.out.println("\nQuintity of "+f.Items+" Now is "+e);
                     
                     
    }
                   else
                   {
                   
    System.out.println("we did FOUND "+f.Teacher_Name);  
                    } 
                    }
                   
                  
    // System.out.println("\n  price ="+t);
                    
                  
    System.out.println("---------------------------------------------------------------------------\n");
                }
          break;
          
          case 
    3: {
              
              
    System.out.println("Enter THE ROOM NUMBER OF TEACHER  ");
              
    int key=input.nextInt();
              
    Link i theList.delete(key);        // delete item
              
    if( != null )
              {
              
               
    System.out.println("Deleted NUMBER OF ROOM : "+  i.Room_Number+"\n");
               
    System.out.println("Delet the ID :  "+i.teacher_ID +"\n");
               
    System.out.println("Delet the Name Of TEACHER : "i.Teacher_Name+"\n" );
               
    System.out.println("Delet the PHONE NUMBER :  "+i.Phone_number+"\n");
              
              
              
    System.out.println("SUCCESSFUL DELET");
              } 
              else
              {
              
              
    System.out.println("Can't delete ");
              
              
    System.out.println("the data still in list "+i);
              }
              
    System.out.print("---------------------------------------------------------------------------\n");
                 } 
              break;
           
           case 
    4: {
                  
    theList.display2();
                  
    System.out.println("Enter ROOM NUMBER:>");
                  
    keyinput.nextInt();
                  
    Link i theList.delete(key);  
                  
    System.out.print("---------------------------------------------------------------------------");
                  
                  
    System.out.println("\nlist after EDIT:>");
                  
    theList.display2();
                  
    System.out.println("---------------------------------------------------------------------------\n");
                 }
            break;
              
                     case 
    5: {
                  
    theList.display2();
                  
    System.out.println("Enter New Teacher  Room NUMBER:>");
                  
    keyinput.nextInt();
                  
    Link i =  theList.insertLast(key);  
                  
    System.out.print("---------------------------------------------------------------------------");
                  
                  
    System.out.println("\nlist after EDIT:>");
                  
    theList.display2();
                  
    System.out.println("---------------------------------------------------------------------------\n");
                 }
            break;
       }
    //end switch
       
        
    if(ConvOption1>6)
        {
        
         
    JOptionPane.showMessageDialog(null"YOUAR INPUT NUMBER NOT IN THE LIST\n              PLEASE, TRY AGAIN");       
        }
         
    Option1 JOptionPane.showInputDialog("\n1-Show List of TEACHERS\n2-SEARCH \n3-Remove \n4-Borrow\n5-Return\n6-Exit");
         
    ConvOption1 Integer.parseInt(Option1);
        }
    //end while
       
    }
    }
    //end mainUser method 

    Link class

    PHP Code:
     class Link 
      

        public 
    int Room_Number
        public 
    String teacher_ID
        public 
    String Teacher_Name
        public 
    String Phone_number// data item 
        
    public Link next// next link in list 

        // ------------------------------------------------------------- 

        
    public Link(int aString bString teacherString Phone// constructor 
        

            
    Room_Number a
            
    teacher_ID b// constructor 
            
    Teacher_Name teacher
            
    Phone_number Phone

        } 
    // set to null) 
            // ------------------------------------------------------------- 

        
    public void displayLink1() 
        
    // display ourself 
        


            
    System.out.println("\t" Teacher_Name "\t\t{" Room_Number "}"); 
            
    System.out.println(""); 
        } 


        public 
    void displayLink2() 
        
    // display ourself 
        

            
    System.out.print("\t" Room_Number); 
            
    System.out.print("\t" teacher_ID); 
            
    System.out.print("\t" Teacher_Name); 
            
    System.out.println("\t\t{" Phone_number "}"); 
        }


    linkList class

    PHP Code:
    class linkList
     

        private 
    Link first// ref to first link on list 

        // ------------------------------------------------------------- 
        
    public linkList() // constructor 
        

            
    first null// no links on list yet 
        


        
    // ------------------------------------------------------------- 
        
    public boolean isEmpty() // true if list is empty 
        

            return (
    first == null); 
        } 
        
    // ------------------------------------------------------------- 
        // insert at start of list 
            
    public String insertFirst(int aString SDString teacherString Phone) { // make 
                                                                            // new 
                                                                            // link 
            
    Link newLink = new Link(aSDteacherPhone); 
            
    newLink.next first// newLink --> old first 
            
    first newLink// first --> newLink 
            
    return first.Room_Number "  " first.teacher_ID "  " first.Teacher_Name "{" first.Phone_number "}"
        } 

        
    // ------------------------------------------------------------- 
        
    public Link find(int key// find link with given key 
        
    // (assumes non-empty list) 
            
    Link current first// start at 'first' 
            
    while (current.Room_Number != key// while no match, 
            

                if (
    current.next == null// if end of list, 
                    
    return null// didn't find it 
                
    else 
                    
    // not end of list, 
                    
    current current.next// go to next link 
            

            return 
    current// found it 
        


        
    // ///////////////////////////////////// 
        
    public Link delete(int key// delete link with given key 
        
    // (assumes non-empty list) 
            
    Link current first// search for link 
            
    Link previous first
            while (
    current.Room_Number != key) { 
                if (
    current.next == null
                    return 
    null// didn't find it 
                
    else { 
                    
    previous current// go to next link 
                    
    current current.next
                } 
            } 
    // found it 
            
    if (current == first// if first link, 
                
    first first.next// change first 
            
    else 
                
    // otherwise, 
                
    previous.next current.next// bypass it 
            
    return current
        } 


        
    // -------------------------------------------------------------
         
     
    public void insertLastint key)    
          {
          
    Link newLink = new Link(key); // make new link
          
    if( isEmpty() )                // if empty list,
             
    first newLink;            // first --> newLink
          
    else
             {
             
    last.next newLink;        // old last --> newLink
             
    newLink.previous last;    // old last <-- newLink
             
    }
             
    last newLink;                // newLink <-- last
          
    }

        
    // ------------------------------------------------------------- 
        
        
    public void displayList() { 
            
    System.out.println("\t\t\n\n                        *~...~*  Welcome *~...~*\n\n "); 
            
    System.out.print("\n\n\t\t               The Menue  \n\n"); 
            
    System.out.println("\n\t :: NAME OF TEACHERS ::\t\t:: NUMBER OF ROOM ::"); 
            
    System.out.println(""); 
            
    Link current first// start at beginning of list 
            
    while (current != null// until end of list, 
            

                
    current.displayLink1(); // print data 
                
    current current.next
                
    // move to next link 
            

            
    System.out.println(""); 
        } 

        public 
    void display2() { 
            
    System.out.print("\t\t        *~...~*  The Menue *~...~*  \n\n"); 
            
    System.out.println("\n\tR.N.    ID              TEACHER NAME \t                PHONE NUMBER\n "); 
            
    Link current first// start at beginning of list 
            
    while (current != null// until end of list, 
            

                
    current.displayLink2(); // print data 
                
    current current.next
                
    // move to next link 
            

            
    System.out.println(""); 
        } 
        
    // ------------------------------------------------------------- 
    // end class LinkList 

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,613
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: Phone Directory program

    it have some errors
    You forgot to post the text of the error messages.

    If the errors are that the program does not do what you want, please post the output from the program and add comments to it explaining what is wrong and show what the output should be.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Dec 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Phone Directory program


  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,613
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: Phone Directory program

    Please copy the full text of the compiler's error messages and paste them here. Images are hard to work with. I can not copy and paste text from the error message to explain it. With posted text I can.

    Here is a sample of a compiler's error message:
    TestSorts.java:138: cannot find symbol
    symbol  : variable var
    location: class TestSorts
             var = 2;
             ^
    It shows the source line and line number and describes the error. I can't see the source line and line number from the image you posted.

    The above error message was from using the javac command.

    With an IDE you need to find someone that can come to your PC, look at its screen and help you solve the errors.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Dec 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Phone Directory program





  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,613
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: Phone Directory program

    Sorry, I can not copy text from images to be able to suggest fixes for the errors.
    You need to copy and paste the text of the error messages here.

    One problem I can see is the compiler cannot find a definition for the last variable. Where is it defined?
    Is its definition in scope (within the same pair of {}s) where it is referenced?

    That is the same problem for all the cannot find errors.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. need help with phone number program for homework
    By stevolabo in forum What's Wrong With My Code?
    Replies: 6
    Last Post: March 23rd, 2012, 07:34 PM
  2. HELP!! Phone Directory Program
    By lahegemon in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 6th, 2011, 08:27 AM
  3. Phone Directory code
    By lahegemon in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 3rd, 2011, 11:47 PM
  4. Java Error cannot be applied to (java.lang.String), phone book entry program.
    By iceyferrara in forum What's Wrong With My Code?
    Replies: 5
    Last Post: September 23rd, 2011, 06:32 AM
  5. i like to play this game with my phone and i wanted to make a program to help me
    By Imreallyawesome in forum What's Wrong With My Code?
    Replies: 25
    Last Post: August 12th, 2011, 07:34 PM