For this project, you’ll now get to write your own Java Server. Using what you’ve learned from the Activities, you’re going to create two Java classes: A Server class and a Client class. The server will run first, set up a local connection, and wait for the client. The client will then connect to the server and send some data to be processed.
The server will work as a conversion app. The client will ask for the user to enter a temperature in the form “80F” or “16C” to be converted. Note that the client should be able to enter either Fahrenheit or Celsius temperatures. Invalid entries (being anything not in the format “xF” or “xC” where x is any real float value) should be turned down by the client and the program should ask for new entry until the user enters a valid input. The server should then receive the user’s entry by any means and convert the given temperature into its counterpart, sending the
converted temperature back to the client. The formula for converting temperatures can be found below.
If you’re still not sure about Java programming or how to set up the server/client stuff, check the following two links:
html When writing this program, here’s some things to keep in mind:
● Code written and submitted must be entirely your own. While you may receive help from other students, tutors, TAs, textbooks, or online sources, the code in your project must be written by you and must be your own original code. Copying from any other source will result in a 0 grade and can potentially have further consequences.
● The nature of the app is to collect an entry from the user, send the data to the server, have the server convert the data, send the data back to the client, and display the converted data to the user. The program should run through only once, and both the client and server should terminate once finished. Keep in mind that it’s possible for either the server or the client to terminate while the other is sending data – if this happens it’ll result in a Connection Reset error. If you encounter this error, make sure that both your classes stay connected beyond sending data.
● For this assignment, the program must be entirely consolebased.
No GUI applications or standalone executables will be accepted for this submission.
● Make sure input is validated before it is sent. If invalid data is entered, the program should repeatedly ask the user for new input until the input entered is valid.
● Make sure you close your IO objects and all your sockets. Leaving them open is a security risk. While the risk is negligible on a local host, it’s still good practice to close them when they’re done receiving data.
● The server should send information to the console for good debugging to tell the programmer what it’s doing during RunTime. Keep in check with when connections are made and when data is sent. Good documentation is also important in this regard.
● This program will require you to compile and run two classes at the same time. Some compilers will not allow this; Eclipse and NetBeans will. If you have a different compiler, check to make sure it will run two main programs simultaneously. If it doesn’t, I’d recommend downloading one of the two compilers mentioned; a quick Google search will give you their websites.
● The formulas for converting temperatures are as follows:
o C = (F – 32) / 1.8
o F = (C * 1.8) + 32
o Keep in mind the order of operations!
● Finally, when you’ve finished your program, zip both the .java files and upload them to Moodle.