I am a bit confused. I am trying to make a program that will take the choices you make and display them all simular to this:
Item 1. Sword
Item 2. Shield
Item 3. Potion
Item 4. Potion
but when I try to run it it looks more like this
first
Item 1. Sword
then
Item 1. Shield
Item 2. Shield
then
Item 1. Potion
Item 2. Potion
Item 3. Potion
and so on and so forth. I am unsure of what i am doing wrong.
#include <iostream>
#include <iomanip>
using namespace std;
const int NumItems = 7;
const int StringSize = 8;
int choice = 0,
Shown=0,
count = 0,
inList=0;
int main()
{
int YesNo = 1;
double count = 0;
cout << "Welcome to the inn, before you set out on your adventure, \nyou'd best "
<< "gather your equipment. \nWould you like to pack something?\n 1. Yes\n 2. No\n";
cin >> YesNo;
while (YesNo != 2)
{
count++;
cout << "Ok what would you like to pack?\n";
cout << " 1. Sword \n 2. Shield \n 3. Helmet \n 4. Armor \n 5. Potion \n 6. Ether \n 7. Elixir\n";
cin >> choice;
char Items[NumItems][StringSize] =
{ "Sword", "Shield", "Helmet", "Armor",
"Potion", "Ether", "Elixir"};
if ((choice != 1) && (choice != 2) && (choice != 3) &&
(choice != 4) && (choice != 5) && (choice != 6) && (choice != 7))
{
cout << "I'm sorry, what was that? ";
cin >> choice;
}
cout << "alright, i'll put one in your pack. \n"
<< "Your pack contains the following: \n";
for (int index = 0; index < count; index++)
{
cout << "item " << (index + 1) << ". " << Items[choice-1] << endl;
}
cout << "Would you like to pack anything else?\n";
cin >> YesNo;
}
system ("pause");
return 0;
}
please help if you can.