Programming Language: Java Due: April 29th 11
[Pages:2]Programming Language: Java Homework #5 Due: April 29th 11.59PM
Question 1) (14.11 Telephone-Number Word Generator) Standard telephone keypads contain the digits zero through nine. The numbers two through nine
each have three letters associated with them (Fig. 14.27). Many people find it difficult to memorize phone numbers, so they use the correspondence between digits and letters to develop seven-letter words that correspond to their phone numbers. For example, a person whose telephone number is 6862377 might use the correspondence indicated in Fig. 14.27 to develop the seven-letter word "NUMBERS."
Every seven-letter word corresponds to exactly one seven-digit telephone number. A restaurant wishing to increase its takeout business could surely do so with the number 825-3688 (i.e., "TAKEOUT"). Every seven-letter phone number corresponds to many different seven-letter words. Unfortunately, most of these words represent unrecognizable juxtapositions of letters. It is possible, however, that the owner of a barbershop would be pleased to know that the shop's telephone number, 424-7288, corresponds to "HAIRCUT." The owner of a liquor store would, no doubt, be delighted to find that the store's number, 233-7226, corresponds to "BEERCAN." A veterinarian with the phone number 738-2273 would be pleased to know that the number corresponds to the letters "PETCARE." An automotive dealership would be pleased to know that the dealership number, 639-2277, corresponds to "NEWCARS."
a) Write a program (TelephoneNumberGenerator.java) that, given a seven-digit number, write to a file every possible seven-letter word combination corresponding to that number. There are 2,187 (37) such combinations. Avoid phone numbers with the digits 0 and 1. Your application should be able to take to command line arguments number and output file. Both of them is optional if no number is given ask the user for the number. And if no output filename is given use number.txt as default. Use -n and -f for command line arguments, so java TelephoneNumberGenerator -n2323456 -fdelete.txt is a possible execution command. Make your class reusable from other classes. They can instantiate a TelephoneNumberGenerator object and call its method generateWords(int number,String fileName). You may have another method which takes a number and returns a String array.
b) Convert this java file into a multi purpose file which can be both an Applet and an application. For the applet case you may have a textfield, a button and a TextArea or you may use dialog boxes to get the number from the user. Be aware that I don't want another file for the Applet. The single class should be able to both Applet and an application.
c) Extend this application to generate only real English words instead of simply printing out the all the seven-letter combinations. This can be done by cross-referencing the combo with a word list. Use the 7 letter words list at . Provide this file (in any form you like as txt or html) with your application. In order to enable just real words user should enable a switch from command like, namely -realOnly. Also add another method which takes a boolean argument beside number and output file name. GenerateWords() method should return a reference to a result object which should have three methods isSuccessful(), getErrorMessage() and getRealToAllRatio(). Real to all ration should return a float between 0 and 1. You should catch any possible IO error and return a reasonable error message.
d) Write a test class AutoTelephoneNumberGenerator.java which takes arguments initial number,count and -realOnly. Then it should instantiate a TelephoneNumberGenerator object and should generate count numbers starting from initial number. And it should print the system time to do it and average RealToAll ratio. All the arguments are optional and if not given you should ask the user missing ones.
e) Add this last automatic generation feature to your applet. Have scrollbars for the Textarea.
Digit Letters 2 A B C 3 D E F 4 G H I 5 J K L 6 M N O 7 P R S 8 T U V 9 W X Y Fig. 14.4 | Telephone keypad digits and letters. Question 2) Built a simple calculator which supports basic arithmetic (integer and floating point). It should support negative values. Should be able to display all the calculations in a scrollable text area. Should support binary, octal, decimal and hexadecimal. You don't need the menus, but you can. Allow the user to save the results to a file (Ask user which file to save). Again built this for dual purpose both Applet and Application. Provide a html file to run the applet. Applet can not save to file so don't display this option to user. Following figure shows the possible buttons but you are completely free to design your own GUI as long as it is functional.
Question 3) This application is to cover how to use other people's libraries. Develop a barcode reader application which allows the end user to select an image for reading and displays the result back to the user. You are free to develop your own GUI. You can use any of the available java barcode reading libraries. Do not call the other java application using Runtime.exec() or ProcessBuilder(). Do not use the provided GUI with the library if there is any. Just instantiate a object and communicate with it via method calls. You may need to use the -classpath option for both java and javac. Like java -classpath .;aaaa.jar;..;bbb.jar MyBarcodeReader. Provide .bat files for windows and .sh files for *nix both compiling and running purposes. In java you can easily read and image with a single line of code.
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- problem set 4 mit opencourseware
- guidelines for alphabetical arrangement of letters and sorting of
- lecture 17 huffman coding hk
- programming language java due april 29th 11
- running head a multilingual pseudoword generator 1
- how to create an algorithm in word
- 12 example playfair cipher eecs at uc berkeley
- algorithms for generating permutations and combinations
- alexis monnerot dumaine to cite this version
- package wordpools the comprehensive r archive network
Related searches
- programming in java pdf
- java programming language book pdf
- the java programming language pdf
- java programming language tutorial pdf
- java programming language pdf download
- java programming language for beginners
- c programming language standard
- c programming language specification
- programming language popularity
- best programming language for games
- which programming language to learn first
- best programming language to learn 2020