Hi I have a basic client server program that I created. I'm confused on how the whole parseDouble() works when adding numbers.
The data is in the form of whole numbers separated by spaces. Such as 1 2 3 4. I was thinking to store each number in an array because I want to add them together and return the result to my client. I'm always open to easier ways!
Im confused how to
1) isolate each number in the string and converting it to a data type such as double
2) adding those values together
The data is in the form of whole numbers separated by spaces. Such as 1 2 3 4. I was thinking to store each number in an array because I want to add them together and return the result to my client. I'm always open to easier ways!
Code:
BufferedReader inFromClient = new BufferedReader (newInputStreamReader(connectionSocket.getInputStream()); FromClient = inFromClient.readLine(); public double CalculateAnswer() { double m = Double.parseDouble( FromClient ); double numbers[] = new double[m]; }
1) isolate each number in the string and converting it to a data type such as double
2) adding those values together
Comment