Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a number guessing game: Step 1: The game creates a n array of 3 integers and fills each element with a random number between

Write a

number

guessing game:

Step 1:

The game

creates

a

n array

of

3

integers

and

fills each element

with a

random number

between

1 to

5

.

Use a

for

loop for fillin

g the array

.

Step 2:

The game asks the player to enter a number. If th

e entered number is in

the array, then the game prints "You Win!". Ot

herwise, it prints "Try Again!" and

asks for another number until the player wins.

Step 3:

When the player wins, the game stops, and prints the cont

ents of the array

on the screen using

another

for

loop.

Bonus:

When creating the array, make sure each number

is

unique.

Example Output:

Guess a number (1 to

5

):

1

Try Again!

4

Try Again!

2

You Win!

The numbers were:

2

5 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

Students also viewed these Databases questions

Question

Discuss your future in the world of business.

Answered: 1 week ago

Question

5. Wyeth Pharmaceuticals

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago