Alright so the code looks like this:
price = 0;
do
{
count = 1;
Console.Write(" Enter price for item {0}", count);
price = Convert.ToDecimal(Console.ReadLine());
count++;
} while (price != -1);
‘count’ is meant to keep track of how many user inputs have been offered, price is meant to change based on user input. However, I have another variable called ‘total’ that needs to be calculated when the user enters -1 and the loop ends, and ‘total’ is meant to be the total value of each user input of ‘price’. I’m sure this is a very basic question but I cannot figure out how to store the value of price and add it all together at the end.
StatisticalPizza is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.