Quote Originally Posted by nadeera View Post
This is basically what I want to do. If I initialize quantity[itemNumber] =0, I get error C2440: 'initializing': cannot convert from 'int' to 'double[8]'.

Code:
const int itemNumber = 8;
    const string coffeeFlavours[itemNumber]= { "CappucinoR", "CappucinoL" "LatteR", "LatteL", "LongBlackR", "LongBlackL", " IceCoffeeR", "IceCoffeeL"};
    double price[itemNumber] = { 10.50, 13.00, 10.50, 13.00, 8.50, 10.00, 11.50, 13.50 };
    double quantity[itemNumber] = 0;
    char pitz; 
    double amountDue = 0, amountDue1, amountDue2,amountDue3,amountDue4, amountReceived , totalDue, change; 
    int customerID, option;
    float sum = 0, n, choice;
    cout << "\n\n\n\t\t\t!!MENU";
    cout << "\n\n\nInsert Customer Order Number : ";
    cin >> customerID;
    cout << "\n\nCustomer No:" << customerID << endl;





    cout << "\n\n            \t\t\t MENU\n" << endl;
    
    cout << "   ==| COFFEE FLAVOURS |==| REGULAR |==| LARGE |==|EXTRA CHARGE|==========";
    cout << "\n   | 1-Cappucino           RM 10.50    RM 13.00  RM 2.00 for Extra Shot |";
    cout << "\n   | 2-Latte               RM 10.50    RM 13.00                         |";
    cout << "\n   | 3-Long Black          RM 8.50     RM 10.00                         |";
    cout << "\n   | 4-Ice Coffee          RM 11.50    RM 13.50  RM 1.00 for Ice Cream  |\n";
    cout << "\n  =======================================================================";
    cout << endl;


    do {
        cout << "\nWhat do you want to order?";
        cin >> option;

        switch (option) {

        case 1:
        A :
          
          cout << "Cappucino" << endl ;
          cout << "How many?";
          cin >> quantity[itemNumber]; 
          cout << "\n\nDo you prefer :";
          cout << "\n\n1-Regular or 2-Large :";
          cin >> choice;
          if (choice == 1)
          {
              cout << "\n\tPrice: RM" << price[0]<< endl;
              amountDue1 = price[0] * quantity[itemNumber];
              cout << "\n\tAmount Due: RM" << amountDue << endl;
          }
          else if (choice == 2)
          {
              cout << "\n\tPrice: RM" << price[1] << endl;
              amountDue1 = price[1] * quantity[itemNumber];
              cout << "\n\tAmount Due: RM" << amountDue << endl;
          }
          else
          {
              cout << "Please enter 1 or 2 only";
              goto A;
          }
        break;
        case 2:
        B :
          
          cout << "Latte" << endl ;
          cout << "How many?";
          cin >> quantity[itemNumber]; 
          cout << "\n\nDo you prefer :";
          cout << "\n\n1-Regular or 2-Large :";
          cin >> choice;
          if (choice == 1)
          {
              cout << "\n\tPrice: RM" << price[2]<< endl;
              amountDue2 = price[2] * quantity[itemNumber];
              cout << "\n\tAmount Due: RM" << amountDue << endl;
          }
          else if (choice == 2)
          {
              cout << "\n\tPrice: RM" << price[3] << endl;
              amountDue2 = price[3] * quantity[itemNumber];
              cout << "\n\tAmount Due: RM" << amountDue << endl;
          }
          else
          {
              cout << "Please enter 1 or 2 only";
              goto B;
          }
        break;
        case 3:
        C :
          
          cout << "Long Black" << endl ;
          cout << "How many?";
          cin >> quantity[itemNumber]; 
          cout << "\n\nDo you prefer :";
          cout << "\n\n1-Regular or 2-Large :";
          cin >> choice;
          if (choice == 1)
          {
              cout << "\n\tPrice: RM" << price[4]<< endl;
              amountDue3 = price[4] * quantity[itemNumber];
              cout << "\n\tAmount Due: RM" << amountDue << endl;
          }
          else if (choice == 2)
          {
              cout << "\n\tPrice: RM" << price[5] << endl;
              amountDue3 = price[5] * quantity[itemNumber];
              cout << "\n\tAmount Due: RM" << amountDue << endl;
          }
          else
          {
              cout << "Please enter 1 or 2 only";
              goto C;
          }
        break;
        case 4:
        D :
          
          cout << "Iced Coffee" << endl ;
          cout << "How many?";
          cin >> quantity[itemNumber]; 
          cout << "\n\nDo you prefer :";
          cout << "\n\n1-Regular or 2-Large :";
          cin >> choice;
          if (choice == 1)
          {
              cout << "\n\tPrice: RM" << price[6]<< endl;
              amountDue4 = price[6] * quantity[itemNumber];
              cout << "\n\tAmount Due: RM" << amountDue << endl;
          }
          else if (choice == 2)
          {
              cout << "\n\tPrice: RM" << price[7] << endl;
              amountDue4 = price[7] * quantity[itemNumber];
              cout << "\n\tAmount Due: RM" << amountDue << endl;
          }
          else
          {
              cout << "Please enter 1 or 2 only";
              goto D;
          }
break;
        default:
            break;

        }
        cout << "\nDo you want to order another (y/n)? ";
        cin >> pitz;
    } while ((pitz == 'y') || (pitz == 'Y'));

    amountDue = amountDue1 + amountDue2 + amountDue3 + amountDue4;
    cout << "\nAmount to be paid: RM" << amountDue;

    do {
        cout << "\n\nYour cash is   : RM";
        cin >> amountReceived;
        if (amountReceived <amountDue){
            cout << "\a\n\t     Your money is not enough! " << endl;
        }
    }

    while (amountReceived <amountDue);

    change = amountReceived- amountDue;
    cout << "\nYour Balance  : RM" << change << "\n\n" << endl << endl;

    cout << "\t\t  For your receipt: ";
    system("pause");
    system("cls");



Code:
const int itemNumber = 8;

cin >> quantity[itemNumber
What you're telling the computer to do is access the 9 th element of the array, but the array only has 8 members. Array start their count at 0. This means the 8 element is your array is 7. There is a mysterious 9 element but you would go out of bounds. I'm not a good coder but this would make it work and keep you in bounds.

Code:
const int itemNumber = 8;

cin >> quantity[itemNumber - 1]