Adrian MT
❔ Making a Vending Machine for Class!
Hey ya'll, I'm new here! I've been having some trouble with this assignment and I was hoping I could get some help.
Below is a snippet of my code so far. Below is a snippet of my code so far. Basically, I got the vending loop portion down, but I can't seem to figure out how to get the program to maintain the number of each item and then provide the total when the user ends the program.
{
Console.WriteLine(" OSU Snacks menu");
Console.WriteLine("Select 1 for Soda --> price = $" + vendingOne);
Console.WriteLine("Select 2 for Cookie --> price = $" + vendingTwo);
Console.WriteLine("Select 3 for Chips --> price = $" + vendingThree);
Console.WriteLine();
string userInput = Console.ReadLine();
double numberSelect = Convert.ToDouble(userInput);
if (numberSelect == 1)
{
Console.WriteLine("You chose soda. How many do you want?");
string quantitySelect = Console.ReadLine();
double qsoda = Convert.ToDouble(quantitySelect);
sodaQuantity += (int)qsoda;
Console.WriteLine("Press y if that is all for today");
string yesNo = Console.ReadLine();
if (yesNo == "n")
continue;
if (yesNo == "y") { Console.WriteLine("Your total is $" + sodaQuantity*vendingOne); Console.WriteLine(); break; }
if (yesNo == "y") { Console.WriteLine("Your total is $" + sodaQuantity*vendingOne); Console.WriteLine(); break; }
30 replies