Your SlideShare is downloading. ×
Cis 355 i lab 5 of 6
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Cis 355 i lab 5 of 6

103
views

Published on

Write a program named GuessGame.java that plays the game “guess the number” as follows: Your program chooses the number to be guessed by selecting an integer at random in the range 1–1000. The program …

Write a program named GuessGame.java that plays the game “guess the number” as follows: Your program chooses the number to be guessed by selecting an integer at random in the range 1–1000. The program then displays the following in a label.

I have a number between 1 and 1000 -- can you guess my number?

Please enter your guess: ____________________

A JTextField should be used to input the guess. A JButton must be provided to allow the user to press each time a guess is entered. As each guess is input, the background color should change to either red or blue. Red indicates that the user is getting warmer, and blue indicates that the user is getting colder. A JLabel should display either Too High or Too Low to help the user zero in on the correct answer. When the user gets the correct answer, Correct! should be displayed, and the JTextField used for input should be cleared and changed to be uneditable. Also, a JButton should be provided to allow the user to play the game again. When the New Game JButton is clicked, a new random number should be generated and the input JTextField changed to be editable. A JButton must be provided to allow the user to exit the application. Also provide a count of the number of guesses the user entered when the correct number is guessed.


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
103
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. SOLUTIONJUG.COMCIS/355 iLab 5 of 6CLICK HERE TO GET THE SOLUTION !!!!!!!!STEP 1: GuessGameWrite a program named GuessGame.java that plays the game “guess the number” as follows:Your program chooses the number to be guessed by selecting an integer at random in the range 1–1000. The program then displays the following in a label.I have a number between 1 and 1000 -- can you guess my number?Please enter your guess: ____________________A JTextField should be used to input the guess. A JButton must be provided to allow the user topress each time a guess is entered. As each guess is input, the background color should change toeither red or blue. Red indicates that the user is getting warmer, and blue indicates that the user isgetting colder. A JLabel should display either Too High or Too Low to help the user zero in on thecorrect answer. When the user gets the correct answer, Correct! should be displayed, and theJTextField used for input should be cleared and changed to be uneditable. Also, a JButton should beprovided to allow the user to play the game again. When the New Game JButton is clicked, a newrandom number should be generated and the input JTextField changed to be editable. A JButtonmust be provided to allow the user to exit the application. Also provide a count of the number ofguesses the user entered when the correct number is guessed.Grading RubricGuessGame Points DescriptionStandard header included 1Must contain programs name, student name, anddescription of the programProgram compiles 1 Program does not have any errorProgram executes 1 Program runs without any errorGUI contains the requiredlabels2GUI contains the label with the initial question, the labelfor the input field, and the label for the Too high or Toolow messageGUI contains input text fieldfor the guess2 GUI contains the input field for entering the guessGUI contains the Guess, NewGame, and Exit buttons3GUI contains the Guess button, New Game button, andExit buttonEach button handles thecorresponding eventsproperly6Each button handles and processes its correspondingbehaviorProgram displays the correctoutput4Program displays the correct messages, changes thecolors appropriately, and displays the count of guesses
  • 2. Subtotal 20STEP 2: Text File I/O (20 points)Write a program called TextFileIO.java to create a file named numbers.dat. Then create analgorithm that writes all even numbered integers from 1 to 100, separated by a comma. After thefile has been created, close and reopen the file and display the results to the screen. After theresults have been displayed append the odd number integers from 1 to 100, separated by a commato the end of the file. Reopen the file and display the results. The contents of the file should be theeven numbers from 1 to 100 separated by a comma followed by the odd number from 1 to 100separated by a comma. The output of this program would be something like the following2,4,6,8,10,12,14,……,98,1002,4,6,8,10,12,14,……,98,100,1,3,5,7,9,……..97,99Grading RubricText File I/O Points DescriptionStandard header included 1Must contain program’s name, student name,and description of the programProgram compiles 2 Program does not have any errorProgram executes 2 Program runs without any errorProgram creates "numbers.dat" file 2 The file numbers.dat exists and is readableProgram writes all even numberintegers from 1 to 100, separated bycommas2All even numbers from 1 to 100 are writtento the file. A comma separates each number.File is closed 1The file is closed after even numbers areprocessedFile is re-opened for reading 1The file is re-opened for reading the evennumbers and commasProgram displays even integers 1Program displays even numbers from 1 to100 separated by commasOdd numbers from 1 to 100 separatedby commas are appended2Odd numbers from 1 to 100 are appended tothe file. A comma separates each number.File is closed 1The file is closed after odd numbers areprocessedFile is re-opened for reading 1The file is re-opened for reading the evenand odd numbers separated by commasFile contents are displayed 1The contents of the file are displayedcorrectly, showing each number separated bya commaCorrect output is displayed 5Program displays the correct output asdescribed aboveSubtotal 20CLICK HERE TO GET THE SOLUTION !!!!!!!!

×