Program That Accept Words And Their Meanings Or Display List Of Words In Lexicographical Order

Apr 15, 2015

Write a menu driven program that either accepts words and their meanings, or displays the list of words in lexicographical order (i.e. as in a dictionary). When an entry is to be added to the dictionary you must first enter the word as one string, and then enter the meaning as separate string. Another requirement - from time to time words become obsolete. When this happens, such word must be removed from the dictionary.

Use the JOptionPane class to enter the information.

Use the concept of linked list to carryout this exercise. You will need at minimum the following classes:

- A WordMeaning class that hold the name of a word and its meaning.
- A WordMeaningNode class that creates the node of information and its link field.
- A WordList class that creates and maintain a linked list of words and their meanings.
- A Dictionary class that test your classes.

For the output, the program should produce two scrollable lists:

- The current list of words and their meanings.
- The list of the deleted words. You need not list the meanings, just the words.

So far, I have everything coded except for the remove method, and I am not sure how to code that. I coded the add method already, but now I don't know where to begin with the remove method in my WordList class. My classes are below.

WordMeaning Class:

public class WordMeaning {
String name;
String definition;
WordMeaning(String t, String d) {
name = t;
definition = d;

[Code] .....

View Replies


ADVERTISEMENT

Accept A String And Display All Palindrome Words

Jan 23, 2015

The program is to accept a string and display all the palindrome words(the words that are same even if they are reversed-------->mom,madam,malayalam etc.)in the string.

I need to solve this program urgently.

There are no syntax errors but after typing in the sentence,no output is displayed. This is my program....

import java.util.*;
class palindrome_test
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
System.out.println("Enter a sentence");
String usersInput=in.nextLine();

[Code] .....

View Replies View Related

How To Reverse Order Of Words In A Sentence

Nov 29, 2012

I want to write an application that inputs a sentence, tokenizes the words with method split and reverse the words (not the letters)...I am stuck at the last part: how to reverse them...should I use the method reverse(); ?

Here is my code..

import java.util.Scanner;
import java.util.StringTokenizer;
public class ReversedWords {
//execute application
public static void main( String [] args) {
//get sentence

[code]....

View Replies View Related

Using Min-heap To Sort List Of Words

May 5, 2015

I am learning to use heaps and as an exercise I am trying to write a program using a heap class I have created to sort words. I have read in words from a file and added them to the heap successfully. I am having some trouble figuring out how I can print out a sorted list of the words. From my understanding of how a min-heap works, if I remove from the min/root node they will always be removed in sorted order. So far I have tried out to do a simple for loop but, only half of the heap is being removed. Not sure if my logic is incorrect of there is an error somewhere in my removeMin() function specifically in the while loop.

public static void main(String[] args) {
Heap heap = new Heap();
heap = read( heap );
for( int i = 0; i < heap.getSize(); i++){
heap.removeMin();

[Code] ....

View Replies View Related

Applet Java GUI Building To Display Words To User

Nov 17, 2014

Implement an applet that display historical facts. The applet will include facts from october 28 to december 4th to test the applet.

What is the best thing to add text in my GUI - JLabel, JTextArea? I am trying to display different words on my csFacts. Once a user click button yesterday and button tomorrow?

public class Facts extends JFrame implements ActionListener{
private JButton button1,button2;
private JPanel panel;
private JLabel label;
TextField ri = new TextField(50);
private void createGUI(){
setDefaultCloseOperation(EXIT_ON_CLOSE);

[Code] .....

View Replies View Related

Use JTextarea To Display Text And Then Prompt Users To Type In Certain Words

Nov 9, 2014

So currently I am trying to use a JTextarea to display text and I then prompt users to type in certain words. I have a few problems that I have encountered. Firstly when I use setText and then if I say setText again after that it erases the previous text that was set. Ideally I want to set text once per line in my whenever a certain task is fulfilled. For example if the text says enter y/n, I want the program to go to the next line once I say y or n. Another problem of course is when I setEditable to true I can edit the whole textArea. I just want to be able to edit the line which I am currently at. Is there anything that I can use that mimics the ACM console program, or even the console down below in most IDE's where everything appears to be done line by line?

Also here is an example of what I am trying to do, along with comments:

Java Code:

console.setText("Math is good!");
console.setText("What is 2+2?: "); //using getText gets the whole line, I want
//everything checked after the colon. That is where the input will be
if(line==4){
console.setText("That is correct");
}
else {
console.setText("That is incorrect");
}
//previous text lines are overriden with new ones. I don't want that, nor do I want to be able to edit the
//whole JtextArea mh_sh_highlight_all('java');

A JtextArea is just not getting the job done.

View Replies View Related

Program To Find Repeated Words

Feb 5, 2014

I have made a program which finds the number of occurrence of the words. It is as follows :

public class B {
public static void main(String[] args) {
Map<String, Integer> mp = new LinkedHashMap<String, Integer>();
String s = "This is me tarun ohri This";
Scanner p = new Scanner(s);
int i = 0;

[Code] .....

Output is coming {This=0, is=1, me=1, tarun=1, ohri=1}

View Replies View Related

Recursive Program To Change Two Four Letter Words Into Each Other?

Oct 28, 2014

SO for my project, we have to create a program where we input two four letter words, and using a list of words our teacher provided us and only changing one letter at a time, make the words match.For example, you input BALD and CALL and it would output BALD BALL CALLWe have to use recursion to do this, and I'm totally lost as to where to even begin.

View Replies View Related

Program Which Uses Porter Stemmer Library For Stemming Words

Jun 7, 2014

i am making a program which uses porter stemmer library for stemming words. I have added/included a jar file "porter-stemmer-1.4-sources.jar" to my project, I am facing an error that "package org.tartarus.martin does not exists" , i am using net beans IDE.

View Replies View Related

I/O / Streams :: Program Is To Find Most Frequently Used Words Across All Input Files

Jul 30, 2014

Program is to find the most frequently used words across all the input files, where each word must appear at least once in each file.

View Replies View Related

If Else - Numbers To Words Conversion

Jul 23, 2014

Convert Number to words using If Else Codes?

View Replies View Related

Convert Numbers From -999 To 999 In Words

May 19, 2014

I'm very new to Java and need to write a program where the user inputs any number from -999 to 999 and it inputs it in words. For ex -24 entered would print negative twenty four or 800 entered would be eight hundred. I need to have at least 2 methods that need to be returned to the main method. When i compile, it says that cannot convert from void to java.lang.string for all the word = ... in my case statements.

import java.util.Scanner; 
public class NumToText {
public static void main (String args[]){
Scanner input = new Scanner (System.in) ;
System.out.println ("Enter number.");
int number = input.nextInt ();
 
 [Code] .....

View Replies View Related

Create Non Repeated Words

Jun 21, 2014

I wrote a code for a "skydiving" program that randomly selects the "maneuvers" to be performed by the skydiver during his skydive. I am almost done with the program. I just need to figure out how to print non repeated maneuvers for each round. Each round may not consist of two of the same maneuvers. The program that I wrote randomly picks the maneuvers but sometimes it still prints out two of the same maneuvers for each round.The following is my code.
 
import java.util.Scanner;
import java.util.Random;
///v.0
public class Testpart2 {
 
[code]...

View Replies View Related

Create Non Repeated Words?

Jun 21, 2014

I wrote a code for a "skydiving" program that randomly selects the "maneuvers" to be performed by the skydiver during his skydive. I am almost done with the program. I just need to figure out how to print non repeated maneuvers for each round. Each round may not consist of two of the same maneuvers. The program that I wrote randomly picks the maneuvers but sometimes it still prints out two of the same maneuvers for each round.

The following is my code

import java.util.Scanner;
import java.util.Random;
///v.0
public class Testpart2 {
public static void main(String[] args) {
Random randomNumbers=new Random();

[code]....

View Replies View Related

Amending Whole Words To Char

Apr 15, 2014

So my goal is to build a word search here. The road block I have run into is how to save words, input from user, into an array. Then once I figure that out I need to try and arrange them in such a way so that they will fit into my array without screwing with one another. It does not have to be working exceedingly well I mean really it can be assumed that the users will not try to screw the program up. Ie one or two words and a fairly large table will be all the input. Here is the program as of now:

import java.util.Random;
import java.util.Scanner;
public class BuildWS
{
int r;
int c;
char[][] array;
String query = " ";
 
[code]....

View Replies View Related

Comparing Words In Same Line

Jan 24, 2015

I have tried to compare word in same line..instally i divided words using split...after that my move got stopped....

View Replies View Related

Hashtable Counting Words

Jan 1, 2015

I was browsing around and I found a question asking to find how many times a word occurred in a sentence. I am using a hashtable, over kill yes but I need to use them more. However my counter is not working, not really sure why.You can see in the main method I have two repeating names but it returns 0.

package frequency;
import java.util.Hashtable;
public class CheckFrequency {
hashtable<String, Word> words = new Hashtable<String, Word>();

[code]....

View Replies View Related

Trim Spaces Between Words

Feb 4, 2014

How can i make sure that when user enter value there is no space between words example :

NEW  YORK MUST BE NEW YORK

View Replies View Related

Extracting Words From Text File

Jan 24, 2014

I have these sample strings in a text file : goldfish, fish, dish, filter and i need to extract them out with letters : "is" and need to print them out in another text file. Currently I am able to read the contents of the file but I am not able to print the same it in the new file.

public class Demo {
public static void main(String[] args) {
String filename = "a.txt";
try {

[code]....

View Replies View Related

Using String Methods To Count Words?

Nov 3, 2014

Aeparated by blanks in a string. For simplicity, use strings without punctuation or other white space characters(tabs, newlines etc). Use a JTextArea to allow the user to enter the text and allow the text area to scroll if necessary. when the user clicks a button to count the words , the total number of words counted is displayed in a textbox that cannot be modified by the user.

now my problem is that i am not getting the counted number to display in the un-editable textbox. i also have the problem where the cusrsor is showing in the middle of the input screen instead of at the top.

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import java.util.*;
public class WordCounter extends JFrame implements ActionListener

[code]....

View Replies View Related

Extract Digits From Between Words Deal And Of

Mar 15, 2015

What I am trying to do is extract the digits from between the words 'deal' and 'of'. I was wondering if this was possible to do with a regular expression or if I should just use a scanner.

UNIQUE Passive - Cleave: Basic attacks deal 20% to 60% of total Attack Damage as bonus physical damage to enemies near the target on hit (enemies closest to the target take the most damage).

Is there a regular expression that I could use in order to extract the '20' and the '60' from the above text. Below is what I have tried, but does not work.

(?<=deals)(d+(?=%))(?=of)

just to make a clarification, these numbers will not be the only numbers and the strings themselves will change. Everything can be considered a variable. The only constants between each string would be the words 'deal' and 'of'. The regex pattern "d+" is not a viable expression for my case

View Replies View Related

Counting Words Contained In Address

Sep 19, 2014

I need to make this program work. It is supposed to count the words contained in the Gettysburg address. I went wrong somewhere but don't know where.

import java.util.Scanner;
public class gettysburgAddress {
public Static void main(String[] args) {
String URLString = "http://cs.armstrong.edu/liang/Lincoln.txt";

[Code] .....

View Replies View Related

String Of Words - Getting First Letter From Each Word?

Mar 26, 2014

If I have a string of words and want to get a letter from each word (let's say the first), how do I code for anything past two?

For example, if I have North Atlantic Treaty Organization and I want to convert it to NATO I would do something like:

charAt(0) for N
charAt(x + 1) for A

But what do I do for anything past the second string? If I do charAt(x ++ 1) I get an error.

View Replies View Related

Program Is To Accept Number And Display New Number After Removing All Zeros

Dec 29, 2014

ex
Sample input:2340980
Sample Output:23498

this is the program i have tried but is dosent work

import java.util.*;
class zero
{
public static void main(String args[])
{

[Code]....

View Replies View Related

Delimiter Function And Number Of Words In String

Apr 20, 2014

Working on my java skills. The is Delimiter function is suppose to return true if there is a delimiter in the string and false otherwise. The main is suppose to call this function and count the number of words in the string:

Here is what I came up with:

import java.util.*;
 public class NumberOfWordsInString {
public static void main (String[] args){
Scanner in= new Scanner (System.in);
String s;

[Code] ....

Somehow my method isn't being successfully called by my main and the following error msg was received:

Exception in thread "main" java.lang.Error: Unresolved compilation problems:

length cannot be resolved or is not a field

The method isDelimiter(char) in the type NumberOfWordsInString is not applicable for the arguments (char[])

at javaimprovements.NumberOfWordsInString.main(Number OfWordsInString.java:10)

line 10:
char ch [] = new char [s.length];

and the main doesn't call the isDelimiter function

View Replies View Related

Counting Number Of Words From User Input

Jan 2, 2015

I tried the following code, OK:

Java Code:

String temp = "hi this sf hello is new what is this";
String[] cmd = temp.split("s");
int num = cmd.length;
System.out.println("number of words are: "+num); mh_sh_highlight_all('java');

However, when i get the input from user , i didnt get the expected result:

Java Code:

System.out.println("Enter the input string to count the words: ");
String[] cmd = new Scanner(System.in).next().trim().split("s");
int num = cmd.length;
System.out.println("number of words are: "+num); mh_sh_highlight_all('java');

Now Result for above code:

Enter the string to count the words:

hi this is new

words are: 1

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved