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: 476
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

Resolved Question:

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

Submitted: 1 year ago.
Category: Homework
Expert:  Ingo U replied 1 year ago.
Hi,
what programming language, compiler, and operating system are you using?
Thanks,
Ingo U
Customer: replied 1 year 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!

Expert:  Ingo U replied 1 year ago.
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 1 year 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 1 year 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 1 year 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.


 

Expert:  Ingo U replied 1 year ago.
How about this:

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

Does that meet your needs?

Regards,
Ingo U
Ingo U, Software Engineer
Category: Homework
Satisfied Customers: 476
Experience: Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
Ingo U and 4 other Homework Specialists are ready to help you
Customer: replied 1 year 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!

Expert:  Ingo U replied 1 year ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
Customer: replied 1 year 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!

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Last | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3121
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3035
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/lanis/2009-4-1_233717_phput9xef_c1pm.jpg Lani S.'s Avatar

    Lani S.

    Tutor

    Satisfied Customers:

    2457
    Registered Nurse, Internet Researcher, Private Tutor
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2341
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1975
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1873
    Bachelors Degree and CPA with Accounting work experience