Description Guess the Random Number Create a simple two-player guessing game. Generate a random number from 1 to 10. Player 1 and Player 2 will then guess the random number. If the two players gave the same number, Player2 should change his/her choice. Whoever guessed the random number correctly wins, otherwise the game will go on.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 1GZ
icon
Related questions
icon
Concept explainers
Question

please use google collab and screenshot

Sample Output:
Player 1: Kat
Player 2: Rod
Kat, please enter a number from 1 to 10: 3
Rod, please enter a number from 1 to 10: 1
Sorry, the random number is 9. Try again.
Kat, please enter a number from 1 to 10:4
Rod, please enter a number from 1 to 10: 6
Sorry, the random number is 3. Try again.
Kat, please enter a number from 1 to 10: 2
Rod, please enter a number from 1 to 10: 2
No cheating, Rod! Please enter a different number: 3
Sorry, the random number is 1. Try again.
Kat, please enter a number from 1 to 10: 4
Rod, please enter a number from 1 to 10: 4
No cheating, Rod! Please enter a different number: 4
No cheating, Rod! Please enter a different number: 4
No cheating, Rod! Please enter a different number: 3
Sorry, the random number is 5. Try again.
Kat, please enter a number from 1 to 10: 2
Rod, please enter a number from 1 to 10: 5
Sorry, the random number is 7. Try again.
Kat, please enter a number from 1 to 10: 6
Rod, please enter a number from 1 to 10: 7
Congrats, Kat! The random number is 6!
Transcribed Image Text:Sample Output: Player 1: Kat Player 2: Rod Kat, please enter a number from 1 to 10: 3 Rod, please enter a number from 1 to 10: 1 Sorry, the random number is 9. Try again. Kat, please enter a number from 1 to 10:4 Rod, please enter a number from 1 to 10: 6 Sorry, the random number is 3. Try again. Kat, please enter a number from 1 to 10: 2 Rod, please enter a number from 1 to 10: 2 No cheating, Rod! Please enter a different number: 3 Sorry, the random number is 1. Try again. Kat, please enter a number from 1 to 10: 4 Rod, please enter a number from 1 to 10: 4 No cheating, Rod! Please enter a different number: 4 No cheating, Rod! Please enter a different number: 4 No cheating, Rod! Please enter a different number: 3 Sorry, the random number is 5. Try again. Kat, please enter a number from 1 to 10: 2 Rod, please enter a number from 1 to 10: 5 Sorry, the random number is 7. Try again. Kat, please enter a number from 1 to 10: 6 Rod, please enter a number from 1 to 10: 7 Congrats, Kat! The random number is 6!
Description
Guess the Random Number
Create a simple two-player guessing
game. Generate a random number from 1
to 10. Player 1 and Player2 will then guess
the random number. If the two players
gave the same number, Player2 should
change his/her choice. Whoever guessed
the random number correctly wins,
otherwise the game will go on.
Transcribed Image Text:Description Guess the Random Number Create a simple two-player guessing game. Generate a random number from 1 to 10. Player 1 and Player2 will then guess the random number. If the two players gave the same number, Player2 should change his/her choice. Whoever guessed the random number correctly wins, otherwise the game will go on.
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole