Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

How to make a hangman game in java

28/10/2021 Client: muhammad11 Deadline: 2 Day

String Problems Page 1

String Problems

Problem 1: Scantron Grading Create a program that uses string methods to simulate grading a test of multiple choice questions using a scantron. The program first asks for the number of questions on the test

(validate that it is at least 3). Then ask for the answer key which is input as a string. Validate that there are exactly the right number of answers. Also answers must only be a, b, c, or d (upper or lower case).

Then ask how many tests there are to grade (validate that it is at least 2). For each student, input their answers (must do the same validation of number of questions and all a, b, c, or d.)

Grade the test. Show the results and the number correct, along with the percentage.

You will write the following three methods: public static String getInput(int numquestions) This function receives the number of test questions as a parameter. Its job is to read the user’s

input from the keyboard and validate it. There are two checks: Make sure it is the proper length, if not loop and allow user to re-enter. You should change the string to all upper case letters to make the second validation easier.

Call isValid to make sure that all characters are only only A, B, C, or D. Loop to allow user to re-enter. This function returns a validated string with all upper case letters. (Note that the prompt “Enter key” or “Enter student answer” is done in main, that way this

same function can be used to input the key and the student answers.) public static boolean isValid(string inputstr) This method receives a String parameter and checks that all the letters are only A, B, C, or D are input. Return false if any invalid letter is found, otherwise return true.

public static int gradeTest(String key, String stuanswers) This method receives two strings as parameters, the key and the student answers. It grades

each test by checking each answer. Generate output as shown below. It also counts the number correct and returns the number of correct answers. Sample Output (Test case 1) How many questions? 5

Enter answer key : aba

Must be exactly 5 answers, re-enter: aBcbD

Test key: ABCBD

How many tests to grade? 3

Enter student 1 answers: bbccd

Question Key Student

1 A B

2 B B correct!

3 C C correct!

4 B C

5 D D correct!

String Problems Page 2

Number correct: 3

Score is 60.0%

Enter student 2 answers: cbcbd

Question Key Student

1 A C

2 B B correct!

3 C C correct!

4 B B correct!

5 D D correct!

Number correct: 4

Score is 80.0%

Enter student 3 answers: daddc

Question Key Student

1 A D

2 B A

3 C D

4 B D

5 D C

Number correct: 0

Score is 0.0%

Also do a second test case of your choice

Problem 2: Hangman Write a program that plays the “hangman” game to guess letters in a word.

What data is needed?

 The word to guess – to be selected and returned by the pickWord function.

 The character that the user guesses

 A string to keep track of all the letters that have been guessed correctly

 A string to keep track of all guesses (to eliminate repeat guesses)

You will to write two methods:

public static String pickWord() //create an array with 10 words in it (or more if you like) //use random number generator to select a word from the array //return this word

Code and TEST this function first to show that it will print random words

You will need a function to display the secret word with ‘-‘ in the unguessed letters and the

guessed letters “revealed”.

public static String reveal(String word, String letters) This method receives as input two strings: the word to be guessed, and a string with all the

correctly guessed characters so far. The job of this method is to create and return a new string

with unguessed letters displayed as ‘-‘ and guessed letters are revealed. You are going to build a

String Problems Page 3

new string to be returned character by character by gluing or concatenating one letter at a time.

Remember you can “glue” two strings together using the + (concatenation) operator.

Loop through each letter in the word to be guessed:

 if it appears in the guessed letter string then “glue” the letter onto the result.

 If not, glue “-“.

(Hint: The indexOf method is VERY useful to determine if a letter is in a string)

You should run some simple tests as you code and debug this function.

So let’s say the word to guess is “hello”. Initially there are no guesses, so the guessed letters

string is empty (“”).

Test should print

System.out.println(maskWord(“hello”, “”)); -----

//”hello” is the word, no letters guessed yet

Next guess is “l” System.out.println(maskWord(“hello”, “l”)); --ll-

//the letter ‘l’ has been guessed

h is not in “hello”, so you append –

e is not in “hello”, so you append –

l IS in “hello”, so append ‘l’

l IS in “hello”, so append ‘l’

o is not in “hello”, so append ‘-‘

Next guess is “h” System.out.println(maskWord(“hello”, “lh”)); h-ll-

//the letters ‘l’ and ‘h’ have been guessed

Once these 2 methods are written, write the code to “play” the game. It will require a loop for

the user to guess. Loop until the word is guessed.

 The user inputs a letter, you need to check if that letter appears in the word

 Make sure to handle upper/lower case letters, so that if the user enterers ‘H’ or ‘h’ it will match ‘h’.

 If it does then you call reveal to show the revealed letters

 You will need to think about how to determine when all the letters are guessed.

Once the basic game works, enhance with:

 Keep a String with of previous guessed letters and don’t allow a letter to be guessed twice (validation)

OPTIONAL: To make it more challenging, give the user only a certain number of “strikes” or

bad guesses.

String Problems Page 4

Sample run (Keeping track of previously guessed letters) I am thinking of a word with 8 letters

--------

Guess a letter: t

Good guess!

-----t--

Guess a letter: h

Bad guess...

-----t--

Guess a letter: r

Good guess!

-----t-r

Guess a letter: h

you already guessed that

Previous letters: thr

Guess a letter: c

Good guess!

c----t-r

Guess a letter: p

Good guess!

c--p-t-r

Guess a letter: d

Bad guess...

c--p-t-r

Guess a letter: m

Good guess!

c-mp-t-r

Guess a letter: d

you already guessed that

Previous letters: thrcpdm

Guess a letter: u

Good guess!

c-mput-r

Guess a letter: e

Good guess!

c-mputer

Guess a letter: o

Good guess!

You won!

TESTING: Show the output from playing the game two differen

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Helping Hand
Unique Academic Solutions
Accounting & Finance Mentor
24/7 Assignment Help
Math Exam Success
Finance Professor
Writer Writer Name Offer Chat
Helping Hand

ONLINE

Helping Hand

I am an elite class writer with more than 6 years of experience as an academic writer. I will provide you the 100 percent original and plagiarism-free content.

$44 Chat With Writer
Unique Academic Solutions

ONLINE

Unique Academic Solutions

I have worked on wide variety of research papers including; Analytical research paper, Argumentative research paper, Interpretative research, experimental research etc.

$37 Chat With Writer
Accounting & Finance Mentor

ONLINE

Accounting & Finance Mentor

I find your project quite stimulating and related to my profession. I can surely contribute you with your project.

$18 Chat With Writer
24/7 Assignment Help

ONLINE

24/7 Assignment Help

I am an elite class writer with more than 6 years of experience as an academic writer. I will provide you the 100 percent original and plagiarism-free content.

$26 Chat With Writer
Math Exam Success

ONLINE

Math Exam Success

This project is my strength and I can fulfill your requirements properly within your given deadline. I always give plagiarism-free work to my clients at very competitive prices.

$47 Chat With Writer
Finance Professor

ONLINE

Finance Professor

I have done dissertations, thesis, reports related to these topics, and I cover all the CHAPTERS accordingly and provide proper updates on the project.

$33 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

White plains middle school - Best interest duty fofa - 1 Page Book Response to book "Angela's Ashes" - Philip carmody melbourne grammar - What three ideals make up the project complexity triangle - Writershub tests - Download the file below - Blue mountains bus routes - What Are The Drawbacks Of Employing A Write My Assignment For Me Service? - Ccu strategic objectives - Week 7 - Journal article - The product spanx is an example of an ordinary innovation - The commonwealth of thieves - Draftkings something went wrong vpn - Jacaranda tree leaf type - 12/40 in simplest form - How to activate ti nspire cas software - As one voice vol 2 - Different kinds of news articles - Operational Planning - Follow All The Below Points And Also Attached, Need Answers For All The Points Below In APA Format With At Least 500 Words Excluding References, Title And No Plagiarism And Need Plagiarism Report - Eastern region women's football league - Aqa business and communication systems unit 9 - Bhopal gas tragedy case study questions - Overlord apartments seneca falls ny - Discussion Board - Rmi client server program in java - Mary kay cosmetics case study - Laws against shoplifting harm principle - Compare and contrast cognitive and psychodynamic - Case Study due Friday 10.31.2020 at 3PM EST - InfoTech Import in Strat Plan (ITS-831) - Super subnetting chart - Colace epocrates - Up down counter jk flip flop - Whitechapel club devil in the white city - #14 - How to cite a screenplay mla - Applying Current Literature to Clinical Practice - Chcdiv001 pdf - Nike supply and demand - Apollo robbins ted talk - Tenancy application form vic - Integral topic assessment answers - Isolation of asa from aspirin tablet - Indian camp ernest hemingway character analysis - As vesta was from latmos hill descending analysis - And your name is jonah - The ccpm dilemma case study - Cisco erp implementation case study - Future trends - George fitzhugh cannibals all summary - Mcdonalds case study - Aqa a level economics grade boundaries - Reverse atar calculator hsc - Global smartphone market share 2015 - Which one of the following is a transition metal - Purpose statement for informative speech - Great victoria street housing executive - 0.1 uf capacitor code - List ways in which secret keys can be distributed to two communicating parties. - H&m in fast fashion continued success - Ob gyn soap note template - Ucs kvm connection failed - Ecological niche worksheet answers - How to take isotonix - West marine case study - Effectiveness of advertisement using aida principle - Determine the specific volume of refrigerant vapor - The axial skeleton lab answers - Health education - One – Group Assessment - Theatrical backdrops crossword clue - You can grow your intelligence author - Wikis as a Cloud-Based Tool - APA - 3 Pages - 3 References - Due 17 Oct - What is a courtroom work group - Helmholtz coil magnetic field derivation - Cell organelle quiz pdf - What is the usual period for cosecant - Emerge manchester mental health - Siemens vl630 mccb catalogue - Chapter 9 auditing the revenue cycle solutions - Watch eye of the storm documentary - Homegirl king princess chords - World vision success stories - Encino dental studio amir jamsheed dds - Best calibre for sambar deer - What is green marketing myopia - Broken hill community credit union internet banking - Springer book template word - Analysis of Information Needs Across the Continuum of Care - 24 hrs from now - Hernandez Family Assessment - The prior probabilities for events a1 and a2 are - Lodgement of security bond form wa - Forms of normalization in dbms - Please provide a two page (double spaced) preliminary analysis of the company Netflix - Collision avoidance marine net quizlet - BUSN603 - Students should not have phones in school