My goal with this code is to store user-inputted price data in a do-while loop so that I can put it through calculations for the shipping address. I decided to go at an approach that allows the array to increase in size with each piece of data inputted. The array does increase in size, but the inputted data gets deleted with every loop. Plus, I have to use a do-while loop
{
int itemList = 0;
string userAnswer;
//This section of the code is to have the user input their data for the later calculations
//The do-while loop is used to count how many items the user has inputted, as well as storing the prices for the later calculations
Console.WriteLine("Enter the price of your item:");
do
{
itemList++;
double[] List = new double[itemList];
for (int i = 0; i < itemList; i++)
{
List[i] = Convert.ToDouble(Console.ReadLine());
}
for (int i = 0; i < itemList; i++)
{
Console.Write(List[i] + " ");
}
Console.WriteLine("Do you wish to enter more item prices? Yes or No");
userAnswer = Console.ReadLine();
if (userAnswer == "No")
{
break;
}
}
while (userAnswer == "Yes");```