The Client/Server communication using TCP Sockets in the java.net package.

In this assignment, you are requested to build a system which allows a school pupil to practise multiple choice tests in math. Design a nd implement a connection - oriented Client / Server communication system in Java, which will do the following:

Client:

c1. Connect to server via a connection - oriented socket.
c2. Read (from socket) and display the prompt message sent (see step s2 in serve r) by the server.
c3. Receives and displays the first math question plus three possible answers from the server.
c4. User then selects and inputs the answer and the client program sends the answer to the server. This process is repeated three times.
c5. Af ter the test is over the client accepts and displays the test result of all 3 questions from the server.
c6 . Close the connection.

Server:

s0 . [Initialization] Create a socket on one of the port numbers in the range above 1024.
s1 .Wait for a client con nection on this socket
s2 .When a client connection is accepted send an acknowledgement (a welcome message) as a sting of text.
s3 . Sends the first question plus three possible answers to the client.
s4 . Receives the answer from the client. Stores and evaluates the answer. This process is repeated three times.
s5 . After that the server sends the result to the client.
s6. Close the connection to the client and then loop back and wait for another connection.

Questions database:

Q1: (A + B)*(A+B)
1. A*A + B*B
2. A*A +A*B + B*B
3. A*A +2*A*B + B*B (correct)
Q2: (A + B)*(A - B)
1. A*A + 2*B*B
2. A*A - B*B (correct)
3. A*A - 2*A*B + B*B
Q3: sin(x)*sin(x) + cos(x)*cos(x)
1. 1 (correct)
2. 2
3. 3

Note: All the communication between the Client and the Server should be in the form of strings.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.