Create a java program to input check users attempts

Assignment Help JAVA Programming
Reference no: EM13974046

Computer JAVA programming

Assishgment on JAVA programming. I want u to do the project with netbeans. here is the assisgment. remmber the project name is project2. you will see in the attachment the project form last semester, but i can't turn it on it has to be defferent it just for u to see the format.

Programming Project- Guessing Game

Part 1

This is the old "I'm thinking of a number between...". When you run the program, the computer randomly generates a number. Then, the user is to guess the number. Upon guessing wrong, the program gives him/her a hint as to whether the guess is too high or too low. Once the number has been guessed, the game is over.

Create a command line Java program to input, keep track of, and check user's attempts to guess a randomly generated number. The input portion of the program will be a continuous loop, only breaking out of it when the user either guesses the correct number, or by entering -1 to signify giving up. After each guess, the user will be informed of his guess being too high, too low, or exactly correct. Upon exiting the loop, the user is given feedback of their guesses (amount guessed too low, amount guessed too high, total amount of guesses).

You'll need to generate a random number to be guessed by the user. Here are some lines of code you'll need:

import java.util.Random; // loads in the library with the code to generate random numbers

Random rand = new Random(); // creates a new Random object with which to work

int value = rand.nextInt(32)+1; // this is the line of code that grabs the random number itself

After the user is enters a guess, output a message. For example, "Your guess is larger than the random value. Next guess: ". Or, "You've guessed correct!" if the number guessed matches the random number the program generated.

Example of how this program's output should look after it runs:

run:

Guess the number I'm thinking of, from 1-32: 16

Your guess is larger than the random value. Next guess:

8

Your guess is larger than the random value. Next guess:

4

Your guess is smaller than the random value. Next guess:

6

You've guessed correct!

Total number of guesses: 4

****

Smaller Guesses: 1

*

Larger Guesses: 2

**

I can tell by the look on your face that you've notice the asterisks. They are my poor text representation of a bar graph. Your bar graph should look just as bad as mine. If the total number of guesses is 5, then 5 asterisks should be underneath for a graphical representation. And so on with the next two statistics. Asterisks should be displayed one-by-one with a printf (not println) statement in a loop. Looping however many times it must to represent the appropriate number of guesses.

Break large problems into smaller pieces!

Sometimes it is useful for beginners to complete a smaller, simpler program before tackling the full project. Start with an easy program that only completes part of the project. Name your project 'project2' and your main class 'GuessingGame'. Always use class, variable and project names that clearly describe what you are creating.

Needed Loops: There should be (1) while loop and (3) for loops in this program, with a few if, if-else conditionals. Inside each "for loop" should be a System.out.printf("*"); statement. But after the loop, how do you do a line-feed so your next print statement doesn't appear on the same line as your asterisks?

Please Design First

Dividing a larger problem into smaller sub-problems is an important technique in computer programming.

It is a good practice to design your software before you write the code. Here are some design tasks you should complete before you start:

Write out a list of variables you think you will need (e.g. int totalGuesses; // count of many guesses altogether scores)

Flow chart (or Pseudo code) the selection statement(s) to decide if the guess was too high, too low, or the equivalent number

Flow chart (or Pseudo code) the loop, include the check for -1 input and update of variables

In other words, have some idea about HOW you are going to solve the problem, BEFORE you try to solve the problem.

Part 2- GUI Version

Be sure to complete part one, run it, test it, make sure it is perfect before you start part 2.

Read the GUI programming sections at the end of chapters 1 through 4. Create a second version of the program that uses GUI Dialog boxes to input the guesses and to output the results. Same calculations, same results, much of the code may be a copy and paste from part 1, just use a GUI for the input and output of the data.

I would create part 2 by adding a NEW main class java file (e.g. GuessingGameGUI) to the existing project. Do not change or delete your part 1 code, I want to see both programs.

OBJECT OF THE GAME (not required):

When you've completed this assignment, see if you can beat the game. The object of the game is to discover the algorithm you can use to never exceed 5 wrong guesses. HINT: The object of the game changes to never exceed 7 wrong guesses when you change the random number from 1-32 to 1-128. There is an algorithm in computer science you are looking for.

Something to think about:

How are random numbers generated in a computer?

Attachment:- Guessing Game.zip

Reference no: EM13974046

Questions Cloud

Calculating the marginal profit : If the Mexican company is only willing to pay $27 for the part and CMR has excess capacity, should CMR accept the order? What will be the marginal profit if any? (Show your computations)
What sensory input contributes to our perception of flavor : What is CIPA? What might life be like with it? What does it say about our sense of pain? How do the four primary mechanoreceptors work to give you different qualities of touch? What sensory input contributes to our perception of flavor
Journal entry to record overhead applied to jobs : a. Prepare a journal entry to record overhead applied to jobs. b. Prepare a journal entry to record actual overhead.
Journal entry to record overhead applied to jobs : a. Prepare a journal entry to record overhead applied to jobs. b. Prepare a journal entry to record actual overhead.
Create a java program to input check users attempts : Create a command line Java program to input, keep track of, and check user's attempts to guess a randomly generated number.
Diagram and description of the cutaneous system : Your team has been asked to create a lecture for a high school psychology class on the perception of pleasure and pain. For your 4 to 5 slides include: A diagram and description of the cutaneous system
Identifies the images relationship to sustainability : Describe the image as a whole, using enough objective details so that your audience will have a good visual impression of the image in question. Again, remember that this is an objective description, using only those items that you can actually se..
Prepare a bank reconciliation : Further checking shows the bank statement figure is the correct one. Prepare a bank reconciliation for August 2004.
Prepare a bank reconciliation : Further checking shows the bank statement figure is the correct one. Prepare a bank reconciliation for August 2004.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write java program to print price of table-furniture company

Write down the Java program for furniture company. Ask user to select P for Pine, O for Oak or M for Mahogany. Illustrate the price of table produced with chosen wood.

  Create an array of five employee objects

Create an array of five Employee objects. Prompt the user to enter data for each Employee. Do not allow duplicate ID numbers to be entered.

  Overview in this assignment you are provided with an

overview in this assignment you are provided with an interface that contains a generic type.you are asked to create two

  Write a java statement to create an arraylist

Write a java statement to create an ArrayList called list to hold 25 integers - What is the type of the ArrayList defined in question number 1.

  Write the code with comment and output resultinterface and

write the code with comment and output resultinterface and polymorphismimplement a class quiz that implements the

  Program which defines two unconstrained arrays

The enclosed Java code was suppose to address the following problem, where I require in giving comments/criticism/remarks if possible with respect to the Java coding standards.

  1obtaining the new script download and save the attached

1.obtaining the new script download and save the attached comment cgi mailer script form-mail.pl to your servers

  Write java program to read present basic hourly wage

Write down a java program which will input 1. Read present basic hourly wage. Read in workers fist name and socond name.

  Part - 1build a graphical user interface for displaying the

part - 1build a graphical user interface for displaying the image groups cluster in jmjrst. design and implement using

  Which weblogic property is used to control number of queued

Which WebLogic 4.5x/5.x property is used to control the number of queued requests inside the WebLogic server? When I try load *.jsp files, I see the source code of each JSP files in my browser, what is wrong?

  Write an application with three labeled text field

Write an application with three labeled text fields,one each for the initial amount of a savings account, the annual interest rate, and the number of years. Add a button "Calculate" and a read-only text area to display the balance of the savings acco..

  Object-oriented gui drawing editor

A simple object-oriented GUI drawing editor that allows a user to create, move and erase rectangles, squares, circles and lines in an interactive graphics. How can I draw move erase rectangles, squares, circles and lines in GUI/java.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd