How much more time is needed for the answer? write pseudocode to design a phone
ID: 3837239 • Letter: H
Question
How much more time is needed for the answer?
write pseudocode to design a phone contact list program. Your program includes a Graphical User Interface that allows user to add new contacts, update existing contacts, search specific contact from the contact list, sort the csntact list in ascending or descending order, delete an old contact. Your program should also provide help screen, an exit button to close the program and displays error messages for any exceptions.
Input:
-Write a data text file with a list of phone number (10 digits with dashes, 555-555-5555)
-Read text file to retrieve contact info (phone number, first name, last name)
* Read the file into memory (hint: parallel arrays)
-Individual contact info can also be entered from the keypad
Process: (open/read the file, display the menu, close file)
-Maintain the phone list by ADD, UPDATE, DELETE, INQUIRE/SEARCH, SORTING
*When each item on the menu is done, redisplay the menu
Output: (per each navigation menu item)
-Design a GUI screen that include
*Keypad with numbers
*Navigation menu
*Add New Contact ( textbox for first name, last name, textbox for phone number)
*Update Contact (search by phone number to display name and phone OR search by name to display name and phone number)
*Delete Contact from List (change name to blank)
*Inquire: enter phone name or name
*List: Sort list either ascending or descending order by first name or last name
*Help
*Save phone list
*Exit
-Define a CONTACT class
*Fields (phone number, first name, last name)
*Set & get method
*Constructor
*Methods (add, update, delete, save, sort, display the list etc. )
-Object: personal contact list Or company phone directory (inheritance)
*Public class PersonalContact extends Contact { }
Add:
Enter phone number (phone number: range 1-999)
If not found – display message
If name is blank, enter name (first and last)
If name NOT blank, save contact info, display confirm message
Change:
Enter phone number
If not found – display message
IF found – display name and ask for new name
If name is blank, ask for new name
Delete:
Enter phone number
If not found – display message
If found – display name and confirm delete
If confirm is yes – blank out name
If confirm is no – return to menu
If name is blank, display message
Inquire:
Enter phone number
If found – display name
If not found – display message
If found and name is blank – display message
Sort:
Question: sort ascending, descending or return to menu
If return to menu, then return to menu
If ascending- sort phone number ascending
If descending - sort phone number in descending order
After sort, display phone list
Help:
Display menu option and a one description of the function
Save:
Write phone list back to file
Exit:
If file is open, save phone list, close file
Terminate program
Error:
If a menu selection is made that is not displayed (1-9)
Issue message and display the help screen
Can the answer be written in a genral form so that each statement in the pseudocode represents an operation that can be performed in any high-level language please?
Like this forexample:
Module main( )
// Display the starting message....etc.
Call startingMessage( )
Display "Press a key...etc.
Input
// Display Step 1.
Call step1( )
Display "Press key...etc.
Input
End Module
Explanation / Answer
public class GUIMain { public static void main(String args[]){ GUIPhonebook MainGUI = new GUIPhonebook(); Phonebook MainProgram = new Phonebook(); } } import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.File; import java.util.Scanner; /** * 29 April, 2013 * GUI phonebook that allows the user to: * Store entries * Search for entries by name */ class Entry{ public String name, num, notes; } public class GUIPhonebook implements ActionListener{ Scanner stdin = new Scanner(System.in); private final int WINDOW_WIDTH = 270; private final int WINDOW_HEIGHT = 325; private final int TEXT_WIDTH = 20; private final FlowLayout LAYOUT = new FlowLayout(); private final String LEGEND = "Enter the information you wish to store."; private String name, num, notes, code; private JFrame W = new JFrame("Phonebook"); private JTextArea legendArea = new JTextArea(LEGEND, 5, TEXT_WIDTH); private JLabel nameTag = new JLabel("Name"); private JTextField nameText = new JTextField(TEXT_WIDTH); private JLabel numTag = new JLabel("Phone Number"); private JTextField numText = new JTextField(TEXT_WIDTH); private JLabel noteTag = new JLabel("Notes"); private JTextField noteText = new JTextField(TEXT_WIDTH); private JButton entryButton = new JButton("Enter"); private JButton helpButton = new JButton("Help"); private JButton sortButton = new JButton("Sort"); private JButton quitButton = new JButton("Quit"); private JButton searchButton = new JButton("Search"); public GUIPhonebook(){ W.setSize(WINDOW_WIDTH, WINDOW_HEIGHT); W.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); legendArea.setEditable(false); legendArea.setLineWrap(true); legendArea.setWrapStyleWord(true); legendArea.setBackground(W.getBackground()); nameText.setEditable(true); nameText.setBackground(Color.WHITE); numText.setEditable(true); numText.setBackground(Color.WHITE); noteText.setEditable(true); noteText.setBackground(Color.WHITE); entryButton.addActionListener(this); helpButton.addActionListener(this); sortButton.addActionListener(this); searchButton.addActionListener(this); quitButton.addActionListener(this); W.setLayout(LAYOUT); W.add(legendArea); W.add(nameTag); W.add(nameText); W.add(numTag); W.add(numText); W.add(noteTag); W.add(noteText); W.add(entryButton); W.add(helpButton); W.add(sortButton); W.add(searchButton); W.add(quitButton); W.setBackground(Color.GRAY); W.setVisible(true); } public void actionPerformed(ActionEvent e){ name = nameText.getText(); num = numText.getText(); notes = noteText.getText(); while(e.getSource() != quitButton){ //Attempting to enter information returns an error. if (e.getSource() == entryButton){ System.out.print("Enter Name: "); String number; stdin.nextLine(); Phonebook.contactList[Phonebook.num_entries] = new Enter(); Phonebook.contactList[Phonebook.num_entries].name = name; System.out.print("Enter Number: "); number = stdin.nextLine(); Phonebook.contactList[Phonebook.num_entries].number = number; System.out.print("Enter Notes: "); Phonebook.contactList[Phonebook.num_entries].note = stdin.nextLine(); Phonebook.num_entries++; } //Extra credit help function else if (e.getSource() == helpButton){ System.out.println("To store information in the phonebook, fill out the" + " "Name" and" + " "Number" fields." + " "Notes" is optional."); System.out.println("The name you enter will be associated with the number and notes that you enter."); System.out.println("To sort the phonebook alphabetically and display the current entries, click the" + " "Sort" button."); System.out.println("To search for an entry that is stored in the phonebook, click the" + " "Search" button."); System.out.println("To close the phonebook, click the" + " "Quit" button."); break; } else if (e.getSource() == sortButton){ Phonebook.sortList(); Phonebook.listAllContacts(); break; } else if (e.getSource() == searchButton){ System.out.println("Enter the name of the person you wish to find into the Console."); System.out.print("Find: "); code = stdin.next(); stdin.nextLine(); int i; i = Phonebook.index(code); if (i >= 0){ Phonebook.displayContact(Phonebook.contactList[i]); } else{ System.out.println("**No entry with code " + code); break; } break; } } } } import java.io.*; import java.util.*; class Enter { public String name, number, note; } public class Phonebook { public static Enter[] contactList; public static int num_entries; public static Scanner stdin = new Scanner(System.in); public static void main(String args[]) throws Exception{ int i; char C; String code, Command; contactList = new Enter[200]; num_entries = 0; readPhoneBook("phonebook.txt"); System.out.println("Codes are entered as 1 to 8 characters. Use" + " "e" for enter," + " "f" for find," + " "l" for listing all the entries," + " "q" to quit."); Command = null; C = ' '; while(C != 'q'){ System.out.print("Command: "); Command = stdin.next(); C = Command.charAt(0); switch (C) { case 'e': addContact(); break; case 'f': code = stdin.next(); stdin.nextLine(); i = index(code); if (i >= 0) displayContact(contactList[i]); else System.out.println("**No entry with code " + code); break; case 'l': listAllContacts(); break; case 's': sortList(); break; case 'q': CopyPhoneBookToFile("PhoneBook1.txt"); System.out.println("Quitting the application. All the entries are " + "stored in the file PhoneBook1.txt"); break; default: System.out.println("Invalid command Please enter the command again!!!"); } } } public static void readPhoneBook(String FileName) throws Exception { File F; F = new File(FileName); Scanner S = new Scanner(F); while (S.hasNextLine()) { contactList[num_entries]= new Enter(); contactList[num_entries].name = S.next(); contactList[num_entries].number = S.next(); contactList[num_entries].note = S.nextLine(); num_entries++; } S.close(); } public static void addContact() { System.out.print("Enter Name: "); String name = stdin.next(); String number; stdin.nextLine(); contactList[num_entries] = new Enter(); contactList[num_entries].name = name; System.out.print("Enter Number: "); number = stdin.nextLine(); contactList[num_entries].number = number; System.out.print("Enter Notes: "); contactList[num_entries].note = stdin.nextLine(); num_entries++; } public static int index(String Key) { // Function to get the index of a key from an array // if not found, returns -1 for (int i=0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.