Word Game (how To Check That Word Is In Dictionary)

Apr 21, 2014

import java.io.*;
import java.util.Random;
import java.util.Scanner; 
public class WordGame
{
public static void main(String[] args) throws IOException
{
final int RANDOM_LETTERS_COUNT = 10;
final int TRIALS = 10;
int score = 0;

[Code] ....

View Replies


ADVERTISEMENT

Translation Game - Translate A Word Proposed To And Check If Input Response Is Correct

Dec 19, 2013

The project is to develop the game Translate the Word .... It is asking user to translate a word proposed to and check if the input response is correct. At the end of the game score will be calculated and displayed.

Game Play :

1 - Ask the user to specify , through the console , its name and the number of words to offer . It is up to you to handle exceptions (eg number of words greater than the number you provided )
2 - Recover user response ( the word translated ) and check whether to continue . (eg you want to continue (y / n)) after each proposal.
3 - compare the response of the user with that which is preset for the word in question .
4 - Show the score at the end ( or at the breakpoint ) .
5 - Save the file in a user name , the score , the number of questions and the start date and end of the game played .

Some notes to consider :

1 - The language (eg, English - French , English - Arabic , etc. . ): It is up to you to specify the language adopted in the game and inform the user of your choice.
2 - The word bank to offer : It is up to you to develop the appropriate means to get the words to propose to the user. That said , the words and their translations can be retrieved :

a. a TXT file
b . an XML file . ( Tutorials DOM and SAX )
c . CSV file ( OpenCSV Tutorial )
d. a database ( Tutorial Access)
e . through APIs (eg Wordnet and google translate etc . ) .
f . a combination of the previous options a, bc , d and / or e . (eg words stored in a txt file and answers retrieved from the api google translate)
g . etc. .

Examples of files and databases are attached to the project statement . You will need to add one or more external libraries to your project. Click here for details on adding external libraries to Netbeans .

3 - A user will be associated with the question score if he can translate the word correctly. The score for each question can be calculated based on the number of words / questions to be proposed .

Development : In this project you will need at least a class called Question to encapsulate the word and its translations and provide all necessary methods to manipulate the object type Question.

An interface called IParser to make extensible project. Any class that implements IParser is a parser file (XML , TXT , CSV , etc.). / Database. In your project there will be a single class that implements IParser and will be used to retrieve words and their translations.

Add the ability to store the questions and answers of the user on the hard disk. Make the class Serializable Question

View Replies View Related

Check For A Word That Is Contained In A File?

Apr 17, 2014

I need the user to enter the name of a file and check if the word is contained in the dictionary file.

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;
public class SpellChecker{
public static void main(String[] args){

[code]....

I need to read the file and separate the words and save them in a collection after read another file and search each line for one of the words in the collection.

View Replies View Related

Binary Tree - Storing Each Word As String And Int Frequency For Each Time Word Occurs

Apr 27, 2015

I have built a binary tree, from a file. In each node, I am storing each word as a string, and an int frequency for each time the word occurs. For the assignment, I need to find how many words occur only once in the file. I wrote the program, but for some reason I am getting a number different from what my professor is expecting.

As far as I know, this file has loaded into the tree correctly, because all of my other answers in the assignment are correct. What am I doing wrong?

public void findUnique() {
System.out.println("There are " + findUniqueWords(root, 0) + " unique words.");
}
private int findUniqueWords(Node subTree, int uniqueCount) {
// Base Case: At the end of the branch
if(subTree == null){
return uniqueCount;

[Code] ....

View Replies View Related

AutoCorrect / Replace A Word That Is Similar To A Word In File Text

Mar 13, 2015

The intentions of this program is to prompt a user to enter a file name, and then reads the file. The program will prompt the user to enter a word that needs to be corrected. So lets say I have a text file containing "My name is OP and I Like goind to the Park!" I want to change "goind" to "going",

Now, my second method "isSimilar" executes a similar word with more than one same letter and same length, but I dont know how to execute that whole thing in my third method "correctThisLine" . How I can call that isSimilar method and read in that text file and change that word into that?

import java.util.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class WahidMuhammadA3Q2{
String fileName = "AutoCorrectMe.txt";
public static void main (String [] args){

[Code] ....

View Replies View Related

I/O / Streams :: How To Use Java To Generate Word Document From A Word Template

Aug 19, 2014

I am looking for java codes to generate a word document based on a word template, basically, I have a word template created and in my local path, the template has a proper format with some fields which will be filled in after java codes ran. The java codes will fetch one record from a table, and open the word template and then fill the fields in the word template, and created a new word document and save it in another folder.

I found this example: [URL] which is similar except it uses xml template instead of word template, how to make it work to change the template from xml to word (docx) template?

View Replies View Related

Comparing Typed Word To The Set Word In Object

Jul 1, 2014

Here's My Code.

package bin;
import java.util.Scanner;
public class AppletMain{
public static void main(String[] args){
Scanner oneinput = new Scanner(System.in);
String one;

[Code] ....

I am trying to get it to compare the word I type in to the set word in the object 'secretword'. I have tried everything from equal to == to compareTo, I even created a two hundred line program to do this SIMPLE problem.

View Replies View Related

Create Word Game Using Classes And Objects

Feb 14, 2015

For class, we need to create a word game using classes and objects.

The game is played in rounds. The player is presented with a word that is missing letters. The player has to fill in the missing spaces with their letter guesses. The words presented are chosen with a random number generator which has been provided for us. At the end of the game, the player is shown their score.

In steps, I have to:

-Welcome the player.
-Present the puzzle.
-Allow the player to fill in the blanks.
-Have the program check responses for correct/incorrect input.
-End the game if they have three misses, or continue if they complete the puzzle.

Now, to start, I have a class for the number generator, a class to store the array of 25 words, and a class for the game itself.

View Replies View Related

Word Puzzle Game - Add Extra No Occurrences

Oct 20, 2014

I have a simple Word Program here called PuzzleGame.java. It works perfectly but I wanted to add some bells and whistles to it. So I want to be able that if the user selects the same letter more than once a message comes up letting the user know that "That letter has already been selected, try another letter."

I am certain that if would go in the 'else' of the 'if( )' that I am providing.

import java.util.Scanner;
public class PuzzleGame {
public static void main(String[] args){
String secretPhrase = "BIG JAVA";
String guesses = " ";

[Code] .....

I am thinking maybe after the else in this if statement.

if(guesses.indexOf(secretLetter)== -1) {
System.out.print("-");
notDone = true;
} else {
//something here. I am not sure how to go about it.
System.out.print(secretLetter);
}

View Replies View Related

Design And Implement Word Guessing Game

Dec 29, 2013

I have a project about programing a game in java . In this project you are required to design and implement a word guessing game. In the game, user selects one of the available dictionaries (animals, plants, technical, names, etc. ), and the program randomly chooses one word from that dictionary and displays it by scrambling the letters. The user tries to guess the word while a guess counter starts to count down (lets assume it starts from 5).

While counter counts towards zero, the program chooses -randomly- two misplaced letters and puts them into correct positions to reveal the word more and give the user a hint. However, giving a new hint reduces the total value of the question. Lets say if the initial value of the question is 500 when all letters are scrambled, it reduces to 400 after 1st incorrect guess and hint, then after every incorrect guess it reduces more. You can determine the value of the question by the length of the word. The other details of the game is as follows:

1.You must design at least three classes (for example game, scrambledword, and dictionary).

2.Dictionaries are written in text files. If you design a class for dictionary, it must be constructed by a user chosen category ((animals, plants, technical, names, etc). In the constructor, the dictionary text file corresponding to this category must be opened and read; and words in that dictionary must be read into memory (e.g. String array). You must submit your dictionaries with your code. Do not share dictionaries between friends.

3.The game will record your total points and name in a text file where a hall of fame which has different users and their total points in 10 questions. You can design and implement a class for this.

4.Bonus+5%: Put user interface modules textboxes, buttons, etc Or

a.Use class hierarchy

b.Use of thread and timers and reducing the question value by timer instead of guesses.

View Replies View Related

Multi-word Hangman Game - Spaces Not Displayed When Program Run

Apr 9, 2015

I created a simple Hangman game. It functions correctly, the only issue is when the file contains a phrase (2 or more words), spaces are not displayed when the program is run. For example, if the phrase was Java Programming Forums.

It would appear as _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _.

I want there to be spaces in between the words. How could I fix this? What would I need to add to my code?

import java.util.Scanner;
import java.io.*;
 public class hangman{
public static void main (String[] args) throws FileNotFoundException{
Scanner kb = new Scanner(System.in);
String guess;
String guesses = "";
int wrongGuess = 8;

[Code] ....

View Replies View Related

Hangman Type Game - How Many Times Each Guessed Letter Occurs Within The Word

Jul 31, 2014

The game runs fine, however I have to include how many times each letter that is guessed occurs within the word. For example, if the guess is e, the program should print out: The character e occurs in 3 positions. How would I go about doing this??

/*
* A program that plays simple word guessing game. In this game the user provides a list of words to the program.
* The program randomly selects one of the words to be guessed from this list.
* The player then guesses letters in an attempt to figure out what the hidden word might be.
* The number of guesses that the user takes are tracked and reported at the end of the game.
*/

import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;

[Code] .....

View Replies View Related

How To Print Before And After A Word

Nov 28, 2014

i have completed a code in java so that it can read spaces in a line but when i run it if i put Line 1 test test for example it will print : [ 3] spaces in Line1 test test what i want to print is [ 3] spaces in "Line1 test test" so the diferences is at " Is there any possible thing that i can do?

class Main
{
public static void main( String args[] )
{
System.out.print( "#Enter text : " );
String text = BIO.getString();
while ( ! text.equals( "END" ) )
{

[Code]...

View Replies View Related

Swap The Word?

Jul 8, 2014

i want to swap the word. how could i be able to swap..

for example:-
I/P:-

i want to be a java developer

O/P:-

developer a be to java want

means swap first and last word and all alternate word.

View Replies View Related

2D Arrays - Word Search?

Dec 14, 2014

Okay, so the assignment was creating a word search for the given array. I've created all the code necessary, but I've ran into trouble. This problem occurs with the Up-Forward, Up-Backward, Down-Forward, and Down-Backward sections. If I only set one of these to run, it works. But if I have all 4 set at the same time, it errors out on the first one that runs.

public class P_WordSearch {
public static void main(String[] args) {
char[][] puzzle = {
{'B','O','O','G','S','R','O','W','I','N','G'},
{'E','B','L','G','N','I','M','M','I','W','S'},
{'L','C','E','A','T','I','P','U','P','I','S'},
{'C','M','I','N','C','A','X','Y','O','S','N'},

[Code] ....

View Replies View Related

Regex Word Containing A Substring?

Apr 23, 2014

I'm trying to use regex to find a word containing the substring "cat." I'm not sure why this isn't working?

String match = "^ cat$";

View Replies View Related

Capitalize Second Word Of A String

Feb 16, 2014

So the exercise I'm working on says to have the user enter their name and the program will output their name with the last name in all caps. i made it work BUT the only way i could figure it out was to ask for the first and last names separately creating two strings rather than one.

Of course I want to make it work how it's supposed to (with one string) so that I'm learning. I'm just having trouble conceptualizing how exactly (with varying lengths of names) to tell the program to only capitalize the second word... at first I thought create a substring beginning with the first letter of the last name and ending with the last...but again, therein lies the issue of varying name lengths.

is there a way to create a substring that beginIndex's at the first "space"? then i could just leave the endIndex parameter empty and it would take the whole word into a new string. and from there utilize toUpperCase to the new string?

Here's my code asking for the first and last names separately.

import java.util.Scanner;
class nameEcho {
public static void main ( String [] args ) {
Scanner scan = new Scanner( System.in );
String first;
String last;

[Code] .....

View Replies View Related

Deleting Word From Sentence

Feb 7, 2015

How to delete word "kumar" from sentence

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

[Code] ....

I do not get any output nor any error....

View Replies View Related

Creating A Word Rectangle?

Nov 7, 2014

I was tasked with building a program that, when is given a string by the user, takes it and prints it out as a rectangle. For example, if the user types in "COMPUTER", the output would be:

COMPUTER
OMPUTERC
MPUTERCO
PUTERCOM
UTERCOMP
TERCOMPU
ERCOMPUT
RCOMPUTE

So far, I have created 2 separate strings, and have gotten the output to look like:

COMPUTER
OMPUTERC
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO

So, it works once, but then it doesn't work again. Here is my code:

i was tasked with building a program that, when is given a string by the user, takes it and prints it out as a rectangle. For example, if the user types in "COMPUTER", the output would be:

COMPUTER
OMPUTERC
MPUTERCO
PUTERCOM
UTERCOMP
TERCOMPU
ERCOMPUT
RCOMPUTE

So far, I have created 2 separate strings, and have gotten the output to look like:

COMPUTER
OMPUTERC
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO

So, it works once, but then it doesn't work again. Here is my code:

import java.util.Scanner;
public class WordRectangle {
  /**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner userInput = new Scanner (System.in);

[code]....

View Replies View Related

Why Is The Word Hash Used In LinkedHashSet

Apr 9, 2014

LinkedHashSet=Linked + Hash +Set

In linkedHashSet are the elements stored according to the insertion order or according to the hash value. If the elements are stored according to the insertion order then why is it not named as LinkedSet instead of LinkedHashSet? Why is the word hash used in LinkedHashSet?

View Replies View Related

Any API To Convert Word Into Excel

Aug 7, 2014

I want to write a program to convert word document into excel output..

Is any API available?..

View Replies View Related

String Searching For A Word

Mar 25, 2015

I'm very new to Java, and I'm writing a code to search a string to see how many times the word "dog" is found in it. I'm not sure if this is error-free or the most efficient, but I'd like to keep it simple.

public void run()
{
 
String input = new String("The Dogman was no ordinary dog, nor man, but rather a peculiar dog-like man who barked like a dog, and panted like a dog, he even ate like a dog. He owned a dog named Doglips, and interestingly enough, his favorite food was hotdogs.");
 
println(input);
int index = -1;
int count = 0;
print("Counting dogs:");
inputarray = input.split(" ");
 
[Code] .....

View Replies View Related

Read In A Word And Say If It Is Palindrome

Dec 5, 2014

I recently have tryed to make a java code that reads words and say if its palindrome or not. I want to fix two things but unfortunately i can't do it on my own.

1st thing that i want fix is that when i run the code i have to press 2x times enter..and i dont know why?(i want one time to press it when i write the text)

2nd thing that i want to fix is that when you run it you can put as many words as you can..only when you write "END" the code must ends.

So unfortunately my code runs only for 1 time.(one word)

My code:

class test {
public static void main(String args[]) {
System.out.print( "#Enter text : " );
String text = BIO.getString();
String reverse = BIO.getString();
int length = text.length();
 
[Code] .....

View Replies View Related

How To Select Each Word From String

Oct 1, 2014

What I need to do is ask the user to input some text and then turn it into pig latin. I am confused on how to select each word from the string to determine if it ends in a way or ay. I am to assume that the letters are all lowercase and the text ends with a period.

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

[code]....

View Replies View Related

Inheritance For Word Pattern

Apr 24, 2014

I am in an intro programming class and we got assigned a problem for creating a super class with about a dozen sub classes for generating a random word(via WordGetter class) and then comparing that word to a variety of different patterns(like: does the word contain "re"). We were given the super class which looks like this...

public class Pattern {
public boolean matches(String text) {
return true;
}
public String toString() {
return "(TRUE)";

[code]...

and from this class, we have to write subclasses that override those three methods. I am struggling to understand inheritance and I am not really sure where to even start. Here is the instructions for the first sub class we need to write...

"CONTAINS" SUBCLASS
Constructor: The constructor accepts a String named ‘letters’.

Matches: This pattern matches any text that contains at least one occurrence of each ‘letter’.
toString: produces the text “(CONTAINS <LETTERS>)” where <LETTERS> is the ‘letters’ string.
getLetters(): this method must return letters.
equals(Object): careful on this one. Two Contains are equal if they have the same letters (order is not relevant).
(Example):

Pattern p = new Contains(“re”);
boolean f1 = p.matches(“renew”); // f1 is true
boolean f2 = p.matches(“zoo”); // f2 is false
String s = p.toString(); // s is “(CONTAINS re)”
boolean f3 = p.equals(new Contains(“er”)); // f3 is true.. really..

View Replies View Related

Convert Number To Word

Oct 30, 2014

I generated random numbers from 1 to 13 and I want the numbers 11 12 13 and 1 to be output as jack queen king and ace respectively.

View Replies View Related







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