How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Ingo U Your Own Question

Ingo U
Ingo U, Software Engineer
Category: Homework
Satisfied Customers: 755
Experience:  Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
44076068
Type Your Homework Question Here...
Ingo U is online now
A new question is answered every 9 seconds

additional requirements

This answer was rated:

Write a spell checking program which uses a dictionary of words (input by the user as a string) to find misspelled words in a second string, the test string. Your program should prompt the user for the input string and the dictionary string. A valid dictionary string contains an alphabetized list of words.


 


Functional requirements:



  1. For each word in the input string, your program should search the dictionary file for the given word. If the word is not in the dictionary, you program should print the message "Unknown word found" to standard output.

  2. After traversing the entire input string, your program should print a message describing the total number of misspelled words in the string.

  3. A dictionary string may contain words in uppercase, lowercase, or a mixture of both. The test string may also combine upper and lower case letters. You program should recognize words regardless of case. So if "dog" is in the dictionary string, the word "dOG" should be recognized as a valid word. Similarly, if "CaT" is in the dictionary string, the word "cat" she be recognized as a valid word.

  4. Within a string, a word is a white-space delimited string of characters. So the last word in "Hello world!" is "world!".

Hi,
what programming language, compiler, and operating system are you using?
Thanks,
Ingo U
Customer: replied 3 years ago.


Hello,


This is for java, we use eclipse, and windows 7 I believe... Let me know if I answered any of that incorrectly (sorry, I get lost in the language of everything, I think that's half my problem!)


Thanks!

Would you have a previous project created in that environment that you could upload for me to use as a reference? You could put it all in a zip folder and upload to wikisend.com for example.
Customer: replied 3 years ago.


Previous assignment













Main topics:



Library Methods



User Defined Methods



Write a program that allows a single Player (the user) to play a simple two dice game of chance against a single Opponent (the computer).


Game Description:



  • There is a single Player (human), with two dice.

  • There is a single Opponent (computer), with two dice.

  • Each die is six sided, and each of its sides is labeled with a unique number from 1 to 6, we will call this the value of the die.

  • A game is made up of rounds, a single round is played as such:


1. The computer Opponent rolls it two dice.


2. The dice are displayed.


3. The Player rolls their two dice.


4. The dice are displayed


5. A determination is made as to who won the round, this determination is made via the following rules:


§ Larger values beat smaller values, same values are a tie.


§ A pair is when both dice have the same number on their top faces, the value of the pair is this common value.


§ A non-pair is then when both dice have a different number on their top faces, the major die is the one with the larger value and the minor die the one with the lesser value.


§ Any pair beats any non-pair.


§ Any two pairs are compared by their respective pair values.


§ Any two non-pairs are first compared by their major die values and only in the case of a tie in majors, are compared by their minor die values.


6. The result of the round (with respect to the Player) is announced.


7. The result of the round (with respect to the Player) is tallied, by increasing the number of player wins, ties, or loses by one.



  • The player decides if they wish to play another round.

  • When the game is over, the results of the game (how many rounds the player won, tied and lost) are announced.


Rules and Requirements:



  • You must model a pair of dice as two integers (one for each of the die) named major and minor respectively.

  • You must have one pair of die designated for the Opponent and one pair of die designated for the Player.

  • The value of the major die must be greater than or equal to the value of the minor die. Each time either or both are modified you must verify this condition and re-order them if necessary.

  • Given the following method heading, you must write the corresponding definition for a void return method that displays a brief accounting of the rules and format of your game.

  • Given the following method heading, you must write the corresponding definition for a int return method that generates and returns a random number in the range of low to high inclusive.

  • Given the following method heading, you must write the corresponding definition for a int return method that returns the larger of d1 and d2.

  • Given the following method heading, you must write the corresponding definition for a int return method that returns the smaller of d1 and d2.

  • Given the following method heading, you must write the corresponding definition for a void return method that prints the pair of dice (d1 and d2) to the screen, in some reasonable report format.

  • Given the following method heading, you must write the corresponding definition for a boolean return method that returns true if and only if d1 == d2.

  • Given the following method heading, you must write the corresponding definition for a int return method that determines the result of a single round of the game, (with respect to the Player).

  • Given the following function heading, you must write the corresponding definition for a void return method that generates a reasonable report of a game's outcome statistics.

  • Your program may use additional methods if desired.


· // displays a brief accounting of the rules and format of the gamepublic static void welcome()· // returns an int in the range [low, high]public static int rollDie(int low, int high)public static int majorDie(int d1, int d2)public static int minorDie(int d1, int d2)public static void printDice(int d1, int d2)public static boolean isPair(int d1, int d2)· // return: -1 -> Player lost; 0 -> tie; 1 -> Player wonpublic static int result(int oMajor, int oMinor, int pMajor, int pMinor)· // Report the games outcome statisticspublic static void report(int wins, int ties, int loses)


Sample run(s):


miller.cs: Sample9 Welcome to Computer Dice---------------------------------------------Your opponent will first roll their two dice.Next You will roll your two dice. The outcome of each round will be based on the values of your dice - high beats low, pairs beat non-pairs.--------------------------------------------- Opponent-------- 4 3 Player -------- 4 1Sorry, you lose! Do you wish to play again [y, n] : y Opponent-------- 6 3 Player -------- 5 1Sorry, you lose! Do you wish to play again [y, n] : y Opponent-------- 2 2 Player -------- 4 1Sorry, you lose! Do you wish to play again [y, n] : y Opponent-------- 5 4 Player -------- 5 5Congrats, you win! Do you wish to play again [y, n] : y Opponent-------- 4 3 Player -------- 5 3Congrats, you win! Do you wish to play again [y, n] : n Computer Dice Results---------------------You played 5 rounds. You won 2 rounds.You tied 0 rounds.You lost 3 rounds.---------------------

Customer: replied 3 years ago.


Solution:


import java.util.Scanner;


public class DiceGame {


public static void main(String[] args) {


welcome(); String playAgain = "n";


int numTies = 0; int numLosses = 0; int numWins = 0;


do { int low = 1; int high = 6;


int oppRoll1 = rollDie(low, high); int oppRoll2 = rollDie(low, high); int playerRoll1 = rollDie(low, high); int playerRoll2 = rollDie(low, high);


System.out.println("Opponent"); printDice(oppRoll1, oppRoll2); System.out.println("Player"); printDice(playerRoll1, playerRoll2);


int oMajor = majorDie(oppRoll1, oppRoll2); int oMinor = minorDie(oppRoll1, oppRoll2);


int pMajor = majorDie(playerRoll1, playerRoll2); int pMinor = minorDie(playerRoll1, playerRoll2);


switch (result(oMajor, oMinor, pMajor, pMinor)) { case -1: System.out.println("Sorry, you lose!"); numLosses++; break; case 0: System.out.println("You tied!"); numTies++; break; case 1: System.out.println("Congrats, you win!"); numWins++; break; }


Scanner input = new Scanner(System.in); System.out.println("Do you want to play again? (y, n)"); playAgain = input.next();


} while ("y".equals(playAgain));


report(numWins, numTies, numLosses); }


// displays a brief accounting of the rules and format of the game public static void welcome() { System.out.println("Welcome to Computer Dice"); System.out .println("Your opponent will first roll their two dice.\nNext You will roll two dice.\nThe outcome of each round will be based on the values of your dice -high beats low, pairs beat non-pair"); }


// returns an int in the range [low, high] public static int rollDie(int low, int high) { return low + (int) (Math.random() * ((high - low) + 1)); }


// returns the larger of d1 and d2. public static int majorDie(int d1, int d2) { return Math.max(d1, d2); }


// returns the smaller of d1 and d2. public static int minorDie(int d1, int d2) { return Math.min(d1, d2); }


// prints the pair of dice (d1 and d2) to the screen, in some reasonable // report format. public static void printDice(int d1, int d2) { System.out.println(d1 + " " + d2); }


// returns true if and only if d1 == d2. public static boolean isPair(int d1, int d2) { return (d1 == d2); }


// determines the result of a single round of the game, (with respect to the // Player). return: -1 -> Player lost; 0 -> tie; 1 -> Player won public static int result(int oMajor, int oMinor, int pMajor, int pMinor) { int result = 0;


if (isPair(oMajor, oMinor)) { if (isPair(pMajor, pMinor)) { if (oMajor == pMajor) { result = 0; } else if (oMajor > pMajor) { result = -1; } else { result = 1; } } else { result = -1; } } else if (oMajor == pMajor) { if (oMinor == pMinor) { result = 0; } else if (oMinor > pMinor) { result = -1; } else { result = 1; } } else if (oMajor > pMajor) { result = -1; } else { result = 1; }


return result; }


// Report the games outcome statistics public static void report(int wins, int ties, int loses) { System.out.println("You won" + wins + "rounds.\n You tied" + ties + "rounds.\n You lost" + loses + "rounds."); }


}

Customer: replied 3 years ago.


Sorry, I am at work and previous assignments are on my home computer, but I did have that one saved in an email. I had copied and pasted my program in eclipse to microsoft word to email to my teacher to look over before I submitted it.


 

How about this:

http://wikisend.com/download/782964/SpellChecker.java

Does that meet your needs?

Regards,
Ingo U
Ingo U and 3 other Homework Specialists are ready to help you
Customer: replied 3 years ago.


From glancing at it it looks great, but I will have to wait a couple hours until I am finished with work to verify! I will keep you posted and thanks much!

THIS ANSWER IS LOCKED!

You need to spend $3 to view this post. Add Funds to your account and buy credits.
Customer: replied 3 years ago.


Everything looks great! I'm disappointed that this is our last assignment for the year!!! Thanks so much for all your help, the TA for this class has been just awful, I've struggled through most of the assignments but didn't know where to start with this one. Thanks again!