Anda di halaman 1dari 3

1. Write a phone directory program that keeps its list of names and phone numbers in a file.

The user of the program should be able to look up a name in the directory to find the associated phone number. The user should also be able to make changes to the data in the directory. Every time the program starts up, it should read the data from the file. Before the program terminates, if the data has been changed while the program was running, the file should be re-written with the new data 2. Write java program that reads a text file and makes an alphabetical list of all the words in that file. The list of words is output to another file. Improve the program so that it also keeps track of the number of times that each word occurs in the file. Write two lists to the output file. The first list contains the words in alphabetical order. The number of times that the word occurred in the file should be listed along with the word. Then write a second list to the output file in which the words are sorted according to the number of times that they occurred in the files. The word that occurred most often should be listed first.

3. In mathematics, several operations are defined on sets. The union of two sets A and B is a set that contains all the elements that are in A together with all the elements that are in B. The intersection of A and B is the set that contains elements that are in both A and B. The difference of A and B is the set that contains all the elements of A except for those elements that are also in B. Write a java program that accepts two sets integer numbers named set A and Set B from keyboard, and computes union , intersection and difference of A and B. 4. Write a program that determines and prints the number of duplicate words in a sentence. Treat uppercase and lowercase letters the same. Ignore punctuation. 5. Write a program that uses a StringTokenizer to tokenize a line of text input by the user and places each token in a TreeSet. Print the elements of the TreeSet. [Note: This should cause the elements to be printed in ascending sorted order. 6. Write a java program that reads contents of a file name input.txt; sort contents of the file excluding header content based on Name field and put the sorted content on name.txt file Father_name and put the sorted content on father_name.txt file Age and put the sorted content on age.txt file Compute average age, minimum age, maximum age and sum of ages, and finally append age, minimum age, maximum age and sum of ages in input.txt Content of input.txt looks like the following

Name Mekonnen Aster Belihu

Father_name Abebe Alem Takele

Age 28 22 33

7. Create a program that incorporates Java Swing for the user interface and a database class that utilizes JDBC for data access. Problem specifications and design constraints are listed below. Problem Definition: Develop a program that lets a user enter data, retrieve related data, and update a database table. Database name: Test, table: profile whose attribute are Fname, Lname, id, year, and Department. User Interface: 1. Have a titled window with editable textboxes for user input of a key value and other data to insert, update, delete or retrieve a table instance (row). 2. Include a labeled text field for the key, name (or description), and unit cost (or price). Note from textbook and class examples that an output text field is assigned a value by the setText method. Import the java.text.* package so that setText is available to your program. 3. Add buttons or other components to your window that can initiate action for insert, delete, update, and retrieval. Processing: The program interface is allow the user to insert a new table row, delete a row, update a non-key column in one table row, or retrieve the non-key values for a row. Input may be extracted from textboxes by having a textbox object call the getText() method (e.g. nameTextField.getText() ). For numeric items to be transformed for calculations, parse the text with the appropriate method (e.g. Integer.parseInt). A double item such as cost may be placed in a textbox after creating a NumberFormat object and using its method(s)--see Swing examples.

Anda mungkin juga menyukai