When the user presses a button

Assignment Help JAVA Programming
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).

Reference no: EM13161017

Questions Cloud

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..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write java program that writes names to text file

Create an empty text file called myfile.txt. Write a Java program that writes your names to the text file created. If the file does not exist, include an exception handler for that error.

  Develop java package comprising of class using encapsulation

Develop the Java package comprising of Class and Student with the given requirements. Encapsulation, Method to print student details alone.

  Technical community blog

Write a blog article for a coding and technical community blog.

  Write java application to show successive element of array

Write down java application named GoTooFar which declares the array of 5 integers and stored five values in array. write try block in which you loop to show each successive element of array.

  Write a class named test scores

Write a class named TestScores.The class constructor should accept an array of test scores as an argument.The class should have a method that returns the average of the test scores.

  Write program in java for total amount of customer-s order

Write down program in Java which would ask for clerk to enter total amount of customer's order. Program will then compute seven percent (7%) sales tax.

  Java applet to find how much federal tax we need to pay

Write a java applet to determine how much federal tax we need to pay assuming the tax rate is 12%.  Ask the taxable income.

  Write an application that extends jframe

Write an application that extends JFrame and that displays a phrase in every font size from 6 through 20.

  Java program to print strings given at command line

Write down program Average.java to print strings which it is given at command line, one per line. If nothing is given at command line, then print "No arguments".

  Java-s ability to derive new fonts from existing ones

Find out where on your system these font libraries are located. When you do, please specify the operating system and the location (folder/directory) where you found them. Discuss Java's ability to derive new fonts from existing ones.

  Determine java application on web and structure functions

Determine the Java application on Web and explain how program structure functions. Explain the application in as much detail as possible.

  Define private instance variable to hold boolean value

Write a Java Enumeration "LetterGrade" that represents letter grades A through F including plus and minus grades. Define a private instance variable to hold a boolean value.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd