Hello I've created a client server program. I'm trying to have the server reply back to the client user that strings in the form of Integers separated by spaces is the only accepted input. I need to have two things.
One method that checks the input and makes sure that its in the form of integers separated by spaces
Seconds method that takes the string parses it into integers, adds them together and prints the SUM.
This is the pseudocode that I've come up with
clientInput = inFromClient.readLine(); ***//Check that the input from client is in proper integer format ***//Adds integers together and returns result IntegerSum = parse.Integer(clientInput) + '\n'; //Throw an argument exception if format is incorrect *** if(clientInput.contains(anything other than integers)){ throw IlleagleArgumentException("You can only enter integers in the following format 1 2 10 19 22")} if(loadon==1){ //Display the input received. System.out.println("caught: " + clientInput); //Write out line to socket outToClient.writeBytes(IntegerSum); }
Can someone please show me how to do the code in *** properly?