I have the server application, and the client application, besides the errors which i can't get my finger around, I want the server to ask for a input of the user and send the input to the client. That way the client receives the "Temperature" from the server
Hear is all my code so far.
.....................................................................................
CODE
import java.io.*;
import java.net.*;
import javax.swing.JOptionPane;
public class TemperatureServer
{
//String[] temperatureList =
//{"Take smaller bites",
// "Go for the tight jeans. No they do NOT make you look fat,",
// "One word: inappropriate",
// "Just for today be honest. Tell your boss what you *really* think",
// "You might want to rethink that haircut"
//};
{
double celsiusValue = 0.0; //declares celsiusValue as a double variable
double kelvinValue = 0.0; //declares kelvinValue as a double variable
String userInput = JOptionPane.showInputDialog("Enter the Fahrenheit temperature:");
}
public void go()
{
try
{
System.out.println("Started Temperature server....");
System.out.println("Creating a server socket....");
ServerSocket serverSocket = new ServerSocket(4242);
System.out.println("Server READY to go....");
while(true)
{
Socket sock = serverSocket.accept();
PrintWriter writer = new PrintWriter(sock.getOutputStream());
String temperature = userInput();
writer.println(userInput);
writer.close();
System.out.println(userInput);
}
}
catch(IOException ex)
{
ex.printStackTrace();
}
}
private String userInput()
{
//int random = (int) (Math.random()* adviceList.length);
//return adviceList[random];
}
public static void main(String args[])
{
TemperatureServer server = new TemperatureServer();
server.go();
}
}
.....................................................................................
import java.io.*;
import java.net.*;
//class Socket is in java.net
public class TemperatureClient
{
public void go()
{
try
{
Socket s = new Socket("127.0.0.1",4242);
InputStreamReader streamReader = new InputStreamReader(s.getInputStream());
BufferedReader reader = new BufferedReader(streamReader);
String advice = reader.readLine();
System.out.println("Receiving following message from Server...");
System.out.println("The temperature is"+userInput);
reader.close();
}
catch(IOException ex)
{
ex.printStackTrace();
}
}
public static void main(String args[])
{
TemperatureClient client = new TemperatureClient();
client.go();
}
}
*1lacca: next time please use code tags:

Please someone help.