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 to store employee id number

Use employee data file called employees.txt should comprise at least 5 employee records. Each record stores employee ID number (six digits) last name, first name, middle inital,gender(m or f).

  Statements to print a label

Add the statements to print a label in the following format (the numbers in the example output are correct for input of $4.25 per pound and 41 ounces). Use the formatting object money to print the unit price and total price and the formatting object ..

  The objective is to implement a menu-based system

The objective is to implement a menu-based system for Bank Accounts in order to simulate a very simple banking system. Many structures have to be declared to manage bank accounts.

  Write program in java to calculate interest

Write a program in java to do the following : the following data is stored for each customer in the bank: account number,average balance and number of transaction for each customer it is required to calculate the interest earn

  Create a driver class in java

Your project is to create a driver class that uses SuperJavaIceCreamClass.

  Write a java application to ask number of assignments

Write a java application that accomplishes the following tasks with built in exception handling: ask the number of homework assignment students have submitted in a semester

  Program that initializes an array with ten random integers

Write a JAVA program that initializes an array with ten random integers and then prints four lines of output, containing

  Java threads

This is an introductory assignment on Java synchronization. You will use Java Threads while learning more about concurrency and achieving atomicity using Java’s inbuilt mechanisms.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Develop java code to compute monthly rent for housing units

Develop a java code that computes monthly rent for 3 housing units namely Bungalows,Apartments and hostels. All housing units have got size,color and monthly rental rate.

  Implement the application using a singly linked list

Implement the following application using a singly linked list. This application accepts from console and stores a list of 10 names of your friends in the singly linked list

  The string class and/or the stringbuffer class in java

Create a simple Java application that uses the String class and/or the StringBuffer class and at least 4 of the class methods. Show the code, demonstrate it works properly and describe what it is doing.

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