1. ## Output

I'm wondering why I can't output ounces on the screen in c#
here's the code:

Code:
```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chapter7Problem12
{
class Program
{

static void Main()
{
int numOfOrders = 0;
int count = 1;
int ounces = 0;
double[] array = new double[numOfOrders];

Console.Write("\nEnter number of order: ");

for (int i = 0; i < numOfOrders; i++)
{
Console.Write("\nEnter Weight: ");

if (ounces <= 8)
array[i] = 1.50;
else if ((ounces >= 8) && (ounces < 32))
array[i] = 1.50 + (.50 * (ounces - 8));
else if (ounces >= 32)
array[i] = 13.50 + (.75 * (ounces - 32));

}

Console.Write("\n# Of Orders     Weight               Shipping Charges");
Console.Write("\n-----------------------------------------------------");

for (int i = 0; i < numOfOrders; i++)
{
Console.Write("\n{0,11}{1,11}{2,31:C}\n", count++, ounces, array[i]);
}

}
}
}```

2. Code:
`double[] array = new double[numOfOrders];`
You are creating array of 0 elements. What do you expect will happen when you access a member that is not there?

3. Ok I see what you mean but it still doesn't fix my problem because the array[i] is correct its the ounces variable that I can't get it to output it just prints the last number when I input the numOfOrders here's the code adjustment that I made:

Code:
```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chapter7Problem12
{
class Program
{

static void Main()
{
int numOfOrders = 0;
int count = 1;
int ounces = 0;

Console.Write("\nEnter number of order: ");

double[] array = new double[numOfOrders];

for (int i = 0; i < numOfOrders; i++)
{
Console.Write("\nEnter Weight: ");

if (ounces <= 8)
array[i] = 1.50;
else if ((ounces >= 8) && (ounces < 32))
array[i] = 1.50 + (.50 * (ounces - 8));
else if (ounces >= 32)
array[i] = 13.50 + (.75 * (ounces - 32));

}

Console.Write("\n# Of Orders     Weight               Shipping Charges");
Console.Write("\n-----------------------------------------------------");

for (int i = 0; i < numOfOrders; i++)
{
Console.Write("\n{0,11}{1,11}{2,31:C}\n", count++, ounces, array[i]);
}

}
}
}

I don't know if this is the correct way to fix the problem if you can give me a hint that would be great```

4. I do not know what you store into array - but you store numOfOrders values in it.
On the other hand ounces - you have only 1 variable and so you store in it last read value.

If you expect to output all read values - you need to store them all, so it means - you need to use another array.

PS. Ah, based on the output title - I see array shoudl store "Shipping Charges" - so array is not good name - better use something like

Code:
`double shippingCharges[];`

5. I changed the array[i] name to charges[i] which is better. I understand that I need to make ounces an array. I just don't know how to do it I know how to declare an array I don't know how to assign it to Console.ReadLine without it causing errors

6. Code:
```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chapter7Problem12
{
class Program
{

static void Main()
{
int numOfOrders = 0;
int count = 1;

Console.Write("\nEnter number of order: ");

int[] weight = new int[numOfOrders];
double[] charges = new double[numOfOrders];

for (int i = 1; i < numOfOrders; i++)
{
Console.Write("\nEnter Weight: ");

if(weight[i] <= 8)
charges[i] = 1.50;
else if ((weight[i] >= 8) && (weight[i] < 32))
charges[i] = 1.50 + (.50 * (weight[i] - 8));
else if (weight[i] >= 32)
charges[i] = 13.50 + (.75 * (weight[i] - 32));

}

Console.Write("\n# Of Orders     Weight               Shipping Charges");
Console.Write("\n-----------------------------------------------------");

for (int i = 1; i < numOfOrders; i++)
{
Console.Write("\n{0,11}{1,11}{2,31:C}\n", count++, weight[i], charges[i]);
}

}
}
}```
Ok, I got this far but I get an index out of bounds error with this code snip

if(weight[i] <= 8)

7. ## You gave me just enough to figure it out thanks

Code:
```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chapter7Problem12
{
class Program
{

static void Main()
{
int numOfOrders = 0;
int count = 1;

Console.Write("\nEnter number of order: ");

int[] weight = new int[numOfOrders];
double[] charges = new double[numOfOrders];

for (int i = 0; i < numOfOrders; i++)
{
Console.Write("\nEnter Weight: ");

if(weight[i] <= 8)
charges[i] = 1.50;
else if ((weight[i] >= 8) && (weight[i] < 32))
charges[i] = 1.50 + (.50 * (weight[i] - 8));
else if (weight[i] >= 32)
charges[i] = 13.50 + (.75 * (weight[i] - 32));

}

Console.Write("\n# Of Orders     Weight               Shipping Charges");
Console.Write("\n-----------------------------------------------------");

for (int i = 0; i < numOfOrders; i++)
{
Console.Write("\n{0,11}{1,11}{2,31:C}\n", count++, weight[i], charges[i]);
}