I already wrote a simple Python cash register program on my computer. But now I thought it would be better to write it in Visual Studio using C#, so I started to write the code.
But when I test my program (shown below), it works for the price set and the sell but when I tried to check my wallet, it outputs: "Money in wallet: $".
I actually an experienced C# programmer but I never do C# programming without unity because I usually work in GameDev. I am also an experienced Python programmer so I can write scripts with them.
static void Main(string[] args)
{
int total = (0);
int pricePepsi = (0);
int priceSprite = (0);
string[] choice =
{ "1.Set Sprite's price",
"2.Set Pepsi's price",
"3.Sell Sprite",
"4.Sell Pepsi",
"5.See wallet" };
Console.WriteLine("--------------------CASH REGISTER--------------------");
while (true)
{
foreach (string i in choice)
{
Console.WriteLine(i);
}
Console.Write("Choose one(1/2/3/4/5):");
int choose = Convert.ToInt32(Console.ReadLine());
if (choose == 1)
{
Console.Write("Set Sprite's price to:");
priceSprite = Convert.ToInt32(Console.ReadLine());
}
if (choose == 2)
{
Console.Write("Set Pepsi's price to:");
pricePepsi = Convert.ToInt32(Console.ReadLine());
}
if (choose == 3)
{
Console.Write("Amount of Sprites sold:");
int sellSprite = Convert.ToInt32(Console.ReadLine());
total = (total+(sellSprite * priceSprite));
}
if (choose == 4)
{
Console.Write("Amount of Pepsis sold:");
int sellPepsi = Convert.ToInt32(Console.ReadLine());
total = (total+(sellPepsi * pricePepsi));
}
if (choose == 5)
{
Console.WriteLine("Money in wallet: ",total,"$");
}
}
}