Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use only concepts and programming constructs / syntax we discussed in class. DON T USE THE LOOPS ( for or while ) FOR THIS ASSIGNMENT

Use only concepts and programming constructs/syntax we discussed in class.
DONT USE THE LOOPS (for or while) FOR THIS ASSIGNMENT
Problem #1(10 points)
Write a Java program (name it GuessingGameYourname) that plays guessing game with the user.
A sample game will run like follows.
The number must be a randomly generated integer number between 0 and 9 for each execution.
Give the user up to three times of guessing chance. (Do not use Loop)
For each guessing, program will reply to user Too high or Too low or Correct.
If the user succeeds in guessing at any chance, the program must skip the remaining chances. (hint:
you can use one additional boolean variable to check user guessed correctly or not)
For the last(third) guessing, program will reply to user with INCORRECT,CORRECT and let user
know the correct answer.
Welcome to the game of Guess It!
I will choose a number between 0 and 9.
You will try to guess that number. If your guess wrong, I will tell you
if you guessed too high or too low.
You have 3 tries to guess the number.
OK, I am thinking of a number. Try to guess it.
Your guess? 5// users input
Too high!
Your guess? 1// users input
Too low!
Your guess? 2// users input
Thats correct! Congratulations!
// if third guess is wrong, show incorrect message with the
correct number.
// for example, Sorry, my number is 3.
Thanks for Playing!!

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

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago