0% found this document useful (0 votes)
44 views4 pages

Potion Store

This document contains code for a C# console application that simulates a potion shop. The program allows the user to select from 5 different potions, enter a quantity, and then make a payment. It calculates the total price, checks if the payment is sufficient, and displays the change or amount owed. The user can make multiple purchases by rerunning the program loop or exit the shop. The key functionality includes selecting a potion, calculating prices, validating payment, and displaying results of the transaction.

Uploaded by

kenzuconde75
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views4 pages

Potion Store

This document contains code for a C# console application that simulates a potion shop. The program allows the user to select from 5 different potions, enter a quantity, and then make a payment. It calculates the total price, checks if the payment is sufficient, and displays the change or amount owed. The user can make multiple purchases by rerunning the program loop or exit the shop. The key functionality includes selecting a potion, calculating prices, validating payment, and displaying results of the transaction.

Uploaded by

kenzuconde75
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

using System;

class program
{
static void Main(string[] args)
{
int quantity, totalPrice, payment, change, choice, lack;
bool again = true;

Console.WriteLine("\t\t\tWelcome to the Potion Shop! \n");


Console.WriteLine("We have here: \n");
Console.WriteLine("1. Red Potion (50 pesos each)");
Console.WriteLine("2. Orange Potion (200 pesos each)");
Console.WriteLine("3. Yellow Potion (550 pesos each)");
Console.WriteLine("4. White Potion (1200 pesos each)");
Console.WriteLine("5. Green Potion (40 pesos each)\n");

while (again)
{
Console.Write("Please enter the designated number for the potion you
wanted to buy: ");
int potion = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");

if (potion == 1)
{
Console.Write("Enter the quantity of Red Potion you wanted to buy:
");
quantity = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");

totalPrice = quantity * 50;

Console.Write("Enter the amount of payment: ");


payment = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");

if (payment < totalPrice || payment < 1)


{
Console.WriteLine("Your payment is lower than the total price.
");
Console.WriteLine("The total price for the potion/s is " +
totalPrice + " and you entred payment is " + payment + " less than total price.\
n");
lack = totalPrice - payment;
Console.WriteLine("You're short of " + lack);
Console.WriteLine("");
}
else
{
change = payment - totalPrice;
Console.WriteLine("The total price is: " + totalPrice);
Console.WriteLine("Your payment is: " + payment);
Console.WriteLine("Your change is: " + change);
Console.WriteLine("");
}
}
else if (potion == 2)
{
Console.Write("Enter the quantity of Orange Potion you wanted to
buy: ");
quantity = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");

totalPrice = quantity * 200;

Console.Write("Enter the amount of payment: ");


payment = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");

if (payment < totalPrice || payment < 1)


{
Console.WriteLine("Your payment is lower than the total price.
");
Console.WriteLine("The total price for the potion/s is " +
totalPrice + " and you entred payment is " + payment + " less than total price.\
n");
lack = totalPrice - payment;
Console.WriteLine("You're short of " + lack);
Console.WriteLine("");

}
else
{
change = payment - totalPrice;
Console.WriteLine("The total price is: " + totalPrice);
Console.WriteLine("Your payment is: " + payment);
Console.WriteLine("Your change is: " + change);
Console.WriteLine("");

}
}
else if (potion == 3)
{
Console.Write("Enter the quantity of Yellow Potion you wanted to
buy: ");
quantity = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");

totalPrice = quantity * 550;

Console.Write("Enter the amount of payment: ");


payment = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");

if (payment < totalPrice || payment < 1)


{
Console.WriteLine("Your payment is lower than the total price.
");
Console.WriteLine("The total price for the potion/s is " +
totalPrice + " and you entred payment is " + payment + " less than total price.\
n");
lack = totalPrice - payment;
Console.WriteLine("You're short of " + lack);
Console.WriteLine("");

}
else
{
change = payment - totalPrice;
Console.WriteLine("The total price is: " + totalPrice);
Console.WriteLine("Your payment is: " + payment);
Console.WriteLine("Your change is: " + change);
Console.WriteLine("");

}
}
else if (potion == 4)
{
Console.Write("Enter the quantity of White Potion you wanted to
buy: ");
quantity = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");

totalPrice = quantity * 1200;

Console.Write("Enter the amount of payment: ");


payment = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");

if (payment < totalPrice || payment < 1)


{
Console.WriteLine("Your payment is lower than the total price.
");
Console.WriteLine("The total price for the potion/s is " +
totalPrice + " and you entred payment is " + payment + " less than total price.\
n");
lack = totalPrice - payment;
Console.WriteLine("You're short of " + lack);
Console.WriteLine("");

}
else
{
change = payment - totalPrice;
Console.WriteLine("The total price is: " + totalPrice);
Console.WriteLine("Your payment is: " + payment);
Console.WriteLine("Your change is: " + change);
Console.WriteLine("");

}
}
else if (potion == 5)
{
Console.Write("Enter the quantity of Green Potion you wanted to
buy: ");
quantity = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");

totalPrice = quantity * 40;

Console.Write("Enter the amount of payment: ");


payment = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");

if (payment < totalPrice || payment < 1)


{
Console.WriteLine("Your payment is lower than the total price.
");
Console.WriteLine("The total price for the potion/s is " +
totalPrice + " and you entred payment is " + payment + " less than total price.\
n");
lack = totalPrice - payment;
Console.WriteLine("You're short of " + lack);
Console.WriteLine("");
}
else
{
change = payment - totalPrice;
Console.WriteLine("The total price is: " + totalPrice);
Console.WriteLine("Your payment is: " + payment);
Console.WriteLine("Your change is: " + change);
Console.WriteLine("");

}
}
else
{
Console.WriteLine("You entered a wrong number, Please try again.");

Console.Write("Do you want to buy again? (Press 1 if YES and 2 if NO):


");
choice = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");

if (choice == 2)
{

Console.WriteLine("Thank you for coming, please come again.");


again = false;
}

}
}
}

You might also like