Java swing components and file processing

Assignment Help JAVA Programming
Reference no: EM13765362

Java Swing Components and File Processing:

Program files for each of the following three programs.

1. GuessGame

2. Text File I/O

Step 1: GuessGame

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.

Step 2: Text File I/O

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

Reference no: EM13765362

Questions Cloud

Monopolists are less elastic at all levels of output : In contrast to firms operating in purely competitive industries, demand curves faced by monopolists are less elastic at all levels of output
What elements must be in place for formation of a contract : What elements must be in place for formation of a contract? The Uniform Commercial Code generally regulates commerce or trade on a national basis
Question regarding the right of return : Gyro Company is presently testing a number of new weed control products that it recently developed. To stimulate interest, it has decided to grant to five of its largest customers the unconditional right of return to these products if not fully sa..
Paper detailing the role of corrections officials : Roles of Corrections Officers. Prepare a paper detailing the role of corrections officials
Java swing components and file processing : Java Swing Components and File Processing, 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..
Revenue recognition on book sales with high returns : Chester Books Co. publishes romance novels that are sold to bookstores on the following terms. Each title has a fixed wholesale price, terms f.o.b. shipping point, and payment is due 90 days after shipment. The retailer may return a maximum of 20%..
Latest software and technology : Research the latest software and technology trends surrounding 3D printers. Focus your research on the growth of the 3D printing market. Be prepared to discuss.
Paper detailing the role of corrections officials : Roles of Corrections Officers. Prepare a paper detailing the role of corrections officials
Revenue recognition on book sales with high returns : Chester Books Co. publishes romance novels that are sold to bookstores on the following terms. Each title has a fixed wholesale price, terms f.o.b. shipping point, and payment is due 90 days after shipment. The retailer may return a maximum of 20%..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a java program to simulate a die

Write a Java program to simulate a die. A die has values of either 1, 2, 3, 4, 5 or 6 on the face. You should use the Math.Random() or the java.util.Random() class to generate the values on the die. The program should prompt the user to enter how ..

  Create a bar chart that illustrates sales.

Hal's Used Cars has four salespeople named Pam, Leo, Kim, and Bob. Accept values for the number of cars sold by each salesperson in a month, and create a bar chart that illustrates sales. Save the file as BarGraph.java.

  Mining information from sales data is a common task in both

mining information from sales data is a common task in both traditional and online stores. past sales information can

  Procedural programming and object-oriented programming

What are the similarities between procedural programming and object-oriented programming? What are the differences between procedural programming and object-oriented programming

  Method that receives an array and returns with no duplicate

Write a program that contrains a method that receives an array and returns a new array with no duplicates.

  Write a recursive public method

Write a recursive public method in our BST class that returns a reference to the information in the node containing the smallest value in the tree. The signature of the method is

  Write code that prompts the user to enter a string

Write code that prompts the user to enter a string containing ONLY a series of digits, then complete all of the following operations:

  Data structures and algorithms

Code analysis and programming.

  Uses a 2-d array to store the highest and lowest temperature

Write a program that uses a 2-D array to store the highest and lowest temperatures for each montjh of the year. The program should output the average high, average low, and highest and lowest temperatures of the year. Your program must consist of ..

  Design and implement a set of classes and interfaces and

design and implement a set of classes and interfaces and use them to evaluate the rtas resource requirements.nbspyour

  Show all the objects that are common to both lists

Prepare the segment of code assuming that the objects are of type String and

  Implement the finite field gf

Write a program called "GF2.java" to implement the finite field GF(p n )where p is a prime number andn is a positive integer.You also need to write four methodsto realize.

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