Reference no: EM13161017
Part A-Text messaging is a popular means of communications. Many abbreviations are in common use but are not appropriate for formal communications. Suppose the abbreviations are stored, one to a line, in a text file names abbreviation.txt. For example, the file might contain these lines:
lol
:)
iirc
4
u
ttfn
Write a program that will read a message from another text file and surround each occurrence of an abbreviation with <> brackets. Write the marked message to a new text file.
For example, if the message to be scanned is
How are u today? Iirc? This is your first free day. Hope you are having fun! :)
The new text file should contain
How are <u> today? <Iirc>, this is your first free day. Hope you are having fun! <:)>
Part B- Write an application or applet that implements a simple text editor. Use a text field and a button to get the file. Read the entire file as characters and display it in the JTextArea. The user will then be able to make changes in the text area. Use a Save button to get the contents of the text area and write that over the original file. Create an Exit button to exit the application.
Technical Details: Read each line from the file and then display the line in the text area using the method append (aString). The method getText will return all of the text in the text area in a string that then can be written to the file. The following statement will make the text referenced by editorTextArea scrollable:
JScrollPane scrollPane = new JScrollPane(editorTextArea);
Then add scrollPane to your GUI, just as you would add any other component. The text area editorTextArea does not need to be added to the GUI, but it can be used.
Part C - ELIZA was a program written in 1966 that parodied a psychotherapist session. The user typed sentences and the program used those words to compose a question.
Create a simple applet or GUI application based on this idea. The program will use a label to hold the program's question, a text field into which the use can type an answer, a button for the use to signal that the answer is complete, and a quit button.
The initial text for the question label should read:
What would you like to talk about?"
When the user presses a button, get the text from text field. Now extract the words from the text one at a time and find the largest word of length 4 or more. Let's call this largest word X for now. In response, create a question based on the length of the word. If the word is length 4, the new question is: "Tell me more about X.". If the word length 5, the new questions: "Why do you think X is important?". If the word is length 6 or more, the new question is:"Now we are getting somewhere. How does X affect you the most?". If there is no word of length 4, the new question is:"Maybe we should move on. Is there something else you would like to talk about?" (Hint: you can use the class Scanner to extract the words from a string, assuming blanks separate the words. For example, the following statements:
String text =" one potato two potato ";
Scanner parser = new Scanner (text);
System.out.println(parser.next());
System.out.println(parser.next());
Display one and potato on a separate lines).
Function whose job is to output some sequence
: Write a function whose job is to output some sequence of "interesting" #'s. The numbers should be separated from one another somehow so they don't all run together. This function may need to call another function, where the second function determines..
|
What is the probability
: Suppose that the probability than an incoming email is a spam is p(S), that the probability that the word "w" occurs in the subject line of the spam is p(w), and that q(w) is the probability that the word "w" occurs in the subject line of an email th..
|
Function whose job is to input
: Write a function whose job is to input #'s, non-# to quit, recover from the input failure by calling recover(), and tell main some statistics about the numbers read. A. unsigned readA();
|
The user enter the total rainfall for each of 12 months
: Write a program that lets the user enter the total rainfall for each of 12 months (starting with January) into an array of doubles. The program should calculate and display:the total rainfall for the year,the average monthly rainfall,and the months w..
|
When the user presses a button
: When the user presses a button, get the text from text field. Now extract the words from the text one at a time and find the largest word of length 4 or more. Let's call this largest word X for now. In response, create a question based on the length ..
|
Write a program that takes a positive integer
: Write a program that takes a positive integer from the user and prints the rightmost digit of that integer. This is a sample output: Enter an integer: 1247
|
Desktop publishing system
: Consider a desktop publishing system used to produce documents for various organizations. a. Give an example of a type of publication for which confidentiality of the stored data is the most important requirement
|
Write a program to find that number for nguyen.
: In some Asian countries, 8 and 6 are considered lucky digits. Any number containing only 8s and 6s is considered lucky number, e.g. 6, 8, 66, 668, 88, 886 .... Nguyen is a student who likes mathematics very much. Nguyen likes lucky numbers but only o..
|
Register address machine
: Express the statement X= (A*B)-(C*D)-E in the assembly language of each of 0- memory address machine, 3-register address machine with 3 registers R1,R2,R3, and 2-memory-register-address machine with three registers R1,R2, R3. Your solution should use..
|