How to input values in Multidimensional array

what is the best way to input values into a multidimensional array.  Below is part of my coding for a multidimensional array with a way to input values.

I"m running into a problem when the program is run and the user goes to input values...the inputs aren't lining up with the proper columns... The user has to input the first value and space over twice to input the next value and so .. how can I Have it automatically line up to each corrsponding columns?

The coding isn't my final coding i'm just doing it in parts to get each piece to work before writing the actual program and cleaning it up.

Thanks for the help

#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main()
{
   
                             
   
    int rooms[20] = {1,2,3,4,5,6,7,8,9,10,
                     11,12,13,14,15,16,17,
                     18,19,20};
                     
    const char* floors[16] = {"Floor 1","Floor 2","Floor 3","Floor 4","Floor 5",
                              "Floor 6","Floor 7","Floor 8","Floor 9","Floor 10",
                              "Floor 11","Floor 12","Floor 13","Floor 14",
                              "Floor 15","Floor 16"};
                             
    char hotel_status[16][20];
   
   
    cout <<"Enter Rooms status for each room" <<endl;
    cout <<endl;
    cout <<"Room Status Grid" <<endl;
    cout <<endl;
    cout <<"Room Available - ready for guest   = 'A'" <<endl;
    cout <<"Room Available - needs cleaning    = 'a'" <<endl;
    cout <<"Room Not Available - no cleaning   = 'N'" <<endl;
    cout <<"Room Not Available - need cleaning = 'n'" <<endl;
    cout <<endl;
     
   cout << endl;
   cout << setw(40) <<"ROOMS" <<endl;
   cout <<endl;
   cout << left <<"          ";
   
   for(int i = 0; i < 20; i++)
   {
           
          cout << setw(3) << rooms[i];
         
   }
   cout << endl;
               
             for(int r = 0; r < 16; r++)
             {
                     cout << endl;
                     cout << left << setw(10) << floors[r];
           
                     for(int c = 0; c < 20; c++)
                     {                                                  
                             cin >> hotel_status[r][c];
                           
                     }
             }
         
   cout << endl;
   
   
//-----------------------------------------------------------------------------  
       
   cout << endl;
   cout << setw(40) <<"ROOMS" <<endl;
   cout <<endl;
   cout << left <<"          ";
   
   for(int i = 0; i < 20; i++)
   {
           
          cout << setw(3) << rooms[i];
         
   }
   cout << endl;
               
             for(int r = 0; r < 16; r++)
             {
                     cout << endl;
                     cout <<left <<setw(10) << floors[r];
           
                     for(int c = 0; c < 20; c++)
                     {                          
                             cout << setw(3) << hotel_status[r][c];
                     }
             }
         
   cout << endl;
           
system("pause");
return 0;
}
WestonGroupAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
In a continuous row will be difficult, but the below code will keep the columns consistent:
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
 
using namespace std;
 
int main()
{
   
                             
   
    int rooms[20] = {1,2,3,4,5,6,7,8,9,10,
                     11,12,13,14,15,16,17,
                     18,19,20};
                     
    const char* floors[16] = {"Floor 1","Floor 2","Floor 3","Floor 4","Floor 5",
                              "Floor 6","Floor 7","Floor 8","Floor 9","Floor 10",
                              "Floor 11","Floor 12","Floor 13","Floor 14",
                              "Floor 15","Floor 16"};
                             
    char hotel_status[16][20];
   
   
    cout <<"Enter Rooms status for each room" <<endl;
    cout <<endl;
    cout <<"Room Status Grid" <<endl;
    cout <<endl;
    cout <<"Room Available - ready for guest   = 'A'" <<endl;
    cout <<"Room Available - needs cleaning    = 'a'" <<endl;
    cout <<"Room Not Available - no cleaning   = 'N'" <<endl;
    cout <<"Room Not Available - need cleaning = 'n'" <<endl;
    cout <<endl;
     
   cout << endl;
   cout << setw(40) <<"ROOMS" <<endl;
   cout <<endl;
   cout << left <<"          ";
   
   for(int i = 0; i < 20; i++)
   {
           
          cout << setw(3) << rooms[i];
         
   }
   cout << endl;
               
             for(int r = 0; r < 16; r++)
             {
                     string adjust = "          ";
                     cout << endl;
                     cout << left << setw(10) << floors[r] << endl;
           
                     for(int c = 0; c < 20; c++)
                     {                          
                             cout << adjust;  // <--- reposistion!                      
                             cin >> hotel_status[r][c];
                             adjust += "   "; // move to the next one
                     }
             }
         
   cout << endl;
   
   
//-----------------------------------------------------------------------------  
       
   cout << endl;
   cout << setw(40) <<"ROOMS" <<endl;
   cout <<endl;
   cout << left <<"          ";
   
   for(int i = 0; i < 20; i++)
   {
           
          cout << setw(3) << rooms[i];
         
   }
   cout << endl;
               
             for(int r = 0; r < 16; r++)
             {
                     cout << endl;
                     cout <<left <<setw(10) << floors[r];
           
                     for(int c = 0; c < 20; c++)
                     {                          
                             cout << setw(3) << hotel_status[r][c];
                     }
             }
         
   cout << endl;
           
system("pause");
return 0;
}

Open in new window

0
WestonGroupAuthor Commented:
How would I input a single room value...  I can figure out how to input all values..but how do I do just a single...so how could I reference 1 room and change that value..

So if all values were say   0   how can I change the value in hotel in floor 5 room 5  which is (4,4) ?

thats where i'm running into problems

how could the user be prompted to select that room to change...
0
jkrCommented:
>>how could the user be prompted to select that room to change...

That's relatively simple, just think of it as inputting coordinates, e.g.
int room, floor;
 
cout << "Which place do you want to change?" << endl;
cout << "Floor: ";
cin >> floor;
cout << "Room: ";
cin >> room;
cout "Status: ";
cin >> hotel_status[floor][room];

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.