STEP 1: GuessGame (20 points)
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.
Grading Rubric
GuessGame Points Description
Standard header included 1 Must contain program’s name, student name, and description of the program
Program compiles 1 Program does not have any error
Program executes 1 Program runs without any error
GUI contains the required labels 2 GUI contains the label with the initial question, the label for the input field, and the label for the Too high or Too low message
GUI contains input text field for the guess 2 GUI contains the input field for entering the guess
GUI contains the Guess, New Game, and Exit buttons 3 GUI contains the Guess button, New Game button, and Exit button
Each button handles the corresponding events properly 6 Each button handles and processes its corresponding behavior
Program displays the correct output 4 Program displays the correct messages, changes the colors appropriately, and displays the count of guesses
Subtotal 20
STEP 2: Text File I/O (20 points)
Write a program called TextFileIO.java to create a file named numbers.dat. Then create an algorithm that writes all even numbered integers from 1 to 100, separated by a comma. After the file has been created, close and reopen the file and display the results to the screen. After the results have been displayed append the odd number integers from 1 to 100, separated by a comma to the end of the file. Reopen the file and display the results. The contents of the file should be the even numbers from 1 to 100 separated by a comma followed by the odd number from 1 to 100 separated by a comma. The output of this program would be something like the following
2,4,6,8,10,12,14,……,98,100
2,4,6,8,10,12,14,……,98,100,1,3,5,7,9,……..97,99
Grading Rubric
Text File I/O Points Description
Standard header included 1 Must contain program’s name, student name, and description of the program
Program compiles 2 Program does not have any error
Program executes 2 Program runs without any error
Program creates “numbers.dat” file 2 The file numbers.dat exists and is readable
Program writes all even number integers from 1 to 100, separated by commas 2 All even numbers from 1 to 100 are written to the file. A comma separates each number.
File is closed 1 The file is closed after even numbers are processed
File is re-opened for reading 1 The file is re-opened for reading the even numbers and commas
Program displays even integers 1 Program displays even numbers from 1 to 100 separated by commas
Odd numbers from 1 to 100 separated by commas are appended 2 Odd numbers from 1 to 100 are appended to the file. A comma separates each number.
File is closed 1 The file is closed after odd numbers are processed
File is re-opened for reading 1 The file is re-opened for reading the even and odd numbers separated by commas
File contents are displayed 1 The contents of the file are displayed correctly, showing each number separated by a comma
Correct output is displayed 5 Program displays the correct output as described above
Subtotal 20
* You can also use 2CO option if you want to purchase through Credit Cards/Paypal but make sure you put the correct billing information otherwise you wont be able to receive any download link.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at [email protected].
* As soon as the payment is received, download link of the solution will automatically be sent to the address used in selected payment method.
* Please check your junk mails as the download link email might go there and please be patient for the download link email. Sometimes, due to server congestion, you may receive download link with a delay.
* All the contents are compressed in one zip folder.
* In case if you get stuck at any point during the payment process, please immediately contact us at [email protected] and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please wait for atleast 8 hours for a response from our side. Afterall, we are humans.
* Comments/Feedbacks are truely welcomed and there might be some incentives for you for the next lab/quiz/assignment.
* In case of any query, please donot hesitate to contact us at [email protected].
* MOST IMPORTANT Please use the tutorials as a guide and they need NOT to be used for any submission. Just take help from the material.
******************************************** Good Luck ***************************************************
Any personal information received will only be used to fill your order. We will not sell or redistribute your information to anyone.
We will try our best to resolve the issue and if still persists we can discuss for a refund in case its required.