Creating menu using switch case

Hi, I'm trying to build a menu switch case where I can choose different options using serial monitor. But, it works only for once. When I try to enter the submenu, it doesn't work.

void setup() {
 
  Serial.begin(9600);
}

void loop()
{
  if (Serial.available() > 0);

  {
    int data = Serial.read();
    switch (data)
    {
      case 'A':
        Serial.print("Select drawer:\n1\n2\n3\n4\n5");
        if (Serial.available() > 0);
        {
          int data2 = Serial.read();
          while (Serial.available() > 0) {
       Serial.read();
          switch (data2)
          {
            case 'B':
              Serial.print("1st drawer");

          }
        }
    }
  }
}
}

Hi,
Think about how long it takes for your finger to move from the first key press to the second key. Now think about how long it takes from reading the first byte in the serial buffer to checking to see if there is another byte waiting to be read.

Also:

The semicolons after your 'if' statements are causing the code blocks in the braces {} following it, to do nothing. So, the 'if' statements never change anything, and the code in the blocks is always executed.

PerryBebbington:
Hi,
Think about how long it takes for your finger to move from the first key press to the second key. Now think about how long it takes from reading the first byte in the serial buffer to checking to see if there is another byte waiting to be read.

Sorry I didn't get you.

sabit068:
Sorry I didn't get you.

There are two questions there. Answer them first, for yourself. Then the meaning might become more clear.

aarg:
Also:

The semicolons after your 'if' statements are causing the code blocks in the braces {} following it, to do nothing. So, the 'if' statements never change anything, and the code in the blocks is always executed.

I removed the semi-colon after the if statements but it's still not working.

sabit068:
I removed the semi-colon after the if statements but it's still not working.

I'm not surprised, you really need to think about my questions.

said differently, what happens to your code if within case 'A' there is nothing yet available in the Serial buffer

case 'A':
        Serial.print("Select drawer:\n1\n2\n3\n4\n5");
        if (Serial.available() > 0) {  // <=== WHAT IF IT'S 0 ????

Have you looked at the serial basics tutorial?