Distance Program

Hello, I'm learning how to create a program that asks the user what his/her start point and end point are to give them the distance needed to get there. I am having a hard time figuring out how to make it so that if they pick values example; 5 (Mom room start) and 4(Bathroom end), it will only print 6 feet and nothing else(Start program over). I was searching online for 2D array instructions but couldn't pull it off. I went on and tried this way of doing the program which doesn't seem to be the most practical.
If anyone can please show me an example or help me with a good link of how to do the 2d array I would be most thankful. If anything I would like to learn how to continue to use the if statements in the void distance loop; so that only distance prints

Thank you for reading
Ps: I added a picture of the house and table of distances in a grid to use for the array

// Room Distance Program
void setup() 
{ 
  Serial.begin(9600);   
}

void loop() 
{  
  
  int startPoint=NULL;
  int endPoint=NULL;
   
  //Input selection for start point.
  Serial.print("Select the starting point\n");
  menu();
  getInput(startPoint);
  Serial.print("Your starting point is: ");
  displayInput(startPoint);
  
  //Input selection for end point.
  Serial.print("Select the ending point\n");
  menu();
  getInput(endPoint);
  Serial.print("Your ending point is: ");
  displayInput(endPoint); 
  Serial.print("Your Distance is:");
  distance();
  Serial.print("\n\n\n");
}

void welcome()
{
  Serial.print("Room Distance Program\n");
}
void menu()
{
  delay(3000);  
  Serial.print("  1 - Gerardo's Room\n");
  Serial.print("  2 - Living Room\n");
  Serial.print("  3 - Kitchen\n");
  Serial.print("  4 - Bathroom\n");
  Serial.print("  5 - Mom's room\n");
  Serial.print("\n\n\n");
}

void getInput(int& number)
{
  //This is a loop of to input the value of the whatever is passed into this function
  //This assumes there are only 5 rooms available, and will only accept a number between
  // 1 and 5.
  do
  {
    delay(500);
    if(Serial.available())
    {
      //For some reason 1=49, so we subtract by 48 to give the correct value.
      number=Serial.read()-48;
    }
    
    if((number<0) || (number>5))
    {
      //This lets the user know that they entered a number outside the acceptable range.
      //It also resets number to null, preventing it from looping constantly.
      Serial.print(number);
      Serial.print("\nMust be between 1-5\n");
      number=NULL;
    }
  } while ((number<0) || (number>5) || (number==NULL));
}

void displayInput(int selection)
{
  switch (selection) {
  case 1:
      Serial.print("Gerardo's Room\n");
      break;
  case 2:
      Serial.print("Living Room\n");
      break;
  case 3:
      Serial.print("Kitchen\n");
      break;
  case 4:
      Serial.print("Bathroom\n");
      break;
  case 5:
      Serial.print("Mom's room\n");
      break;
  }
}


void distance()
{ 
  int startPoint=NULL;
  int endPoint=NULL; 
  if((startPoint),(endPoint)=(5),(4))
  {Serial.print("6 feet");}
  else if((startPoint),(endPoint)=(3),(4))
  {Serial.print("13 feet");}
  
 
}

  • the ASCII value of char '1' = 49, '2' = 50 etc thats why you subtract 48

check this (code compiles but the distance table needs to be fixed

NOte that index of tables in C/C++ start with index 0 - so index 5 points to the 6th element. should get you started..

// 2D distance table
int dist[6][6] = { 
{1,2,3,4,5,6},
{7,8,9,10,11,12},
{13,14,15,16,17,18},
{19,20,21,22,23,24},
{25,26,27,28,29,30},
{31,32,33,34,35,36}
};


// Room Distance Program
void setup() 
{ 
  Serial.begin(115200);     // why not use fast communication
  Serial.print("Room Distance Program\n");
}

void loop() 
{  
  int startPoint = 0;
  int endPoint = 0;

  Serial.print("Select the starting point\n");
  menu();
  startPoint = getInput();
  Serial.print("Your starting point is: ");
  displayInput(startPoint);
  
  Serial.print("Select the ending point\n");
  menu();
  endPoint = getInput();
  Serial.print("Your ending point is: ");
  displayInput(endPoint); 

  Serial.print("Your Distance is: ");
  Serial.print( dist[startPoint][endPoint] );  // print the right one from the 2D array
  Serial.print("\n");

  delay(1000);
}


void menu()
{
  delay(3000);  
  Serial.print("  1 - Gerardo's Room\n");
  Serial.print("  2 - Living Room\n");
  Serial.print("  3 - Kitchen\n");
  Serial.print("  4 - Bathroom\n");
  Serial.print("  5 - Mom's room\n");
  Serial.print("\n");
}

// reads one character from input and returns it as an int. 
int getInput()
{
  int nr = -1;
  while (nr < 0)
  {
    if (Serial.available())
    {
      nr = Serial.read() - 48; 
    }
    
    if( nr < 1 || nr >5 )
    {
      Serial.print(nr );
      Serial.print("\nMust be between 1-5\n");
      nr = -1;  //reset it for the while loop.
    }
  } 
  return nr ;
}


void displayInput(int selection)
{
  switch (selection) {
  case 1:
      Serial.print("Gerardo's Room\n");
      break;
  case 2:
      Serial.print("Living Room\n");
      break;
  case 3:
      Serial.print("Kitchen\n");
      break;
  case 4:
      Serial.print("Bathroom\n");
      break;
  case 5:
      Serial.print("Mom's room\n");
      break;
  }
}
//For some reason 1=49, so we subtract by 48 to give the correct value.
      number=Serial.read()-48;

Much easier to remember is number=Serial.read()-'0';