© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
29 replies
Adrian Marquez Trevizo

❔ 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;
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

So I'm making a slot machine for my homework [Answered]
C#CC# / help
4y ago
❔ ✅ Help with searching a class of classes for something?
C#CC# / help
3y ago
Modifier for a class you want as a base class only and making not accessible to external assemblies
C#CC# / help
2y ago
Making a map for restaurant
C#CC# / help
15mo ago