Need help with reading keyboard into an array

And here is the code to go with it

/* max 24 relay controller and pump pulser simulator  
 
 this program takes a serial string like this "12.900.14.14"  and parses it up into variables 
 for relay count 1-12, number of pulses, pulse width, and delay beween pulses. 
 Then it prints that to the serial port like this "Relays 12 Pulses 900 Length 14ms Delay 14ms" 
 
 created 1/7/13
 last edit 2/1/13
 by Will Meyers  
 
 */

unsigned long counter =0; // set counter to 0 
int pulse =52; // pin thats connected to the pulse simulator 
int led = 13; // status led
int dly= 150; // delay between relay functions 

int relay[]={
  14, 15, 16, 17, 18, 19, 20, 21, 30, 31,\
32, 33, 34, 35, 36, 36, 38, 39, 40, 41, 42, 43, 44, 45}; // relay array with all 24 pins 

int pinCount = 24;  // the number  index for the array



void setup() // setup arduino functions 
{

  pinMode (pulse, OUTPUT);  // set pin 52 to an output 
  pinMode (led, OUTPUT); // set pin 13 to an output 

  Serial.begin(9600);    // start serial connection                                                                                                                                                                                                               
  Serial.println("reset");

  for(int n=0; n<pinCount;n++){  // for loop 
    pinMode(relay[n],OUTPUT);  // set all relay pins as output 
    digitalWrite(relay[n], HIGH); // write all relay pins high SETS THEM TO OFF
  }
}

void loop()  // run main loop
{
  if (Serial.available() > 0)  // wait for data 
  {

    int w = Serial.parseInt();   // this is the relay selection variable from 1 -12 
    unsigned long x = Serial.parseInt();  // this is for the pulse counter
    int y = Serial.parseInt(); // this sets how long you want to hold the pulse high  
    int z = Serial.parseInt(); // delay between pulses 
    delay(1); // neccesary delay to use Serial.parseint() ;
    Serial.print("relays "); // print "relays " to serial port 
    Serial.print (w * 2);   // print the w x 2 or relay pins to the serial port 
    Serial.print(" Pulses "); // print "pulses "to the serial port 
    Serial.print(x); // print the var value of x to the serial port
    Serial.print(" Length "); // print "length " to the serial port
    Serial.print(y);
    Serial.print( "ms"); // print the value of y then "ms"  to the serial port
    Serial.print(" delay " );  // print "delay"  to the serial port
    Serial.print(z); // print the value of z  to the serial port
    Serial.println("ms");  //print "ms" to the serial port

    for(int n=0; n < (w * 2); n++){  // for loop relay counter * 2 
      digitalWrite(relay[n], LOW); // set all selected pins low  or ON
      delay(dly); // delay for variable 
    }
    delay(dly * w );  // max delay needed  to turn on all pumps the var dly * relay selection 1-12   

    while(counter<(x)) // while counter is less the x do this loop
    {
      PORTB = 0b10000010; // port adress of the pulse pin 52 pull it HIGH
      delay(y) ;       // delay by y  or how long to hold the pin high 
      PORTB = 0b00000000; // pull everything on this port LOW  
      delay(z);   // delay by z delay between pulses 
      counter++; // increment counter by 1 

      while(counter==(x)) // after counter equals x do this loop
      {
        delay(10); // delay by the value of 10ms 
        PORTB = 0b00000000; // set all pins in this port LOW 
        delay(1000); // delay by the value of 1 second 

        for(int n=0; n < (w * 2); n++){ // for loop  relay counter * 2
          digitalWrite(relay[n], HIGH);// write n # of relay pins HIGH or OFF 
          delay(dly); // delay by variable dly 

        }
        Serial.println("done");  // print "done" to the serial port on a new line 
        return; // fin
      }
    } 
  }
}