This is a Hotel Management Application created by using c# programming language. I'm using only with the basic program using conditional statements and do-while loop.
By this application We take orders from the customer and after completing orders we calculate the bills and ask the tip from customer and added it to bills.
Note:- This app is build in only main method.. No Oops concepts added.. If you need any Oops related projects just comment below I'll added.
Topics used in this code:-
1.Switch case used for display items..
2.if-else conditional statements used for categories
3. do-while is used to display the item types and items multiple times whenever user click on 'y'. if user click on 'n' or any other key loop will break and ask tip to add to bill.
4. Here I'm using basic variables only. Here I'm taking different items cost seperately to display in the last bill..
5. You may practice with the code and make changes as you need.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hotel_management
{
class Program
{
static void Main(string[] args)
{
char cont;
string items = "", orderitems="", allitems="";
int itemtype, ordertype;
double itemcost = 0, totalcost = 0, tip=0,bill ;
double idly = 40, dosa = 60, vada = 50, puri = 60;
double pmeals = 80, fmeals = 120, cbiryani = 150, mbiryani = 220;
double burger = 80, pizza = 120, momos = 100, sandwich = 70;
double milkshake = 40, sprite = 50, coke = 50, pepsi = 50;
do
{
Console.WriteLine("Menu");
Console.WriteLine("1. Tiffins \t 2. Meals/Biryani");
Console.WriteLine("3. Snacks \t 4. Drinks");
Console.WriteLine("Choose one option : ");
itemtype = Convert.ToInt32(Console.ReadLine());
switch (itemtype)
{
case 1:
items = "tiffins";
Console.WriteLine("1. Idly \t 2. Dosa");
Console.WriteLine("3. Vada \t 4. Puri");
break;
case 2:
items = "meals";
Console.WriteLine("1. Plate Meals \t 2. Full Meals");
Console.WriteLine("3. Chicken Biryani \t 4. Mutton Biryani");
break;
case 3:
items = "snacks";
Console.WriteLine("1. Burger \t 2. Pizza");
Console.WriteLine("3. Chicken Biryani \t 4. Mutton Biryani");
break;
case 4:
items = "drinks";
Console.WriteLine("1. Milk Shakes \t 2. Sprite");
Console.WriteLine("3. Coke \t 4. Pepsi");
break;
default:
Console.WriteLine("Invalid Choice");
break;
}
if (itemtype > 0 && itemtype < 5)
{
Console.WriteLine("What type of " + items + " You want :");
ordertype = Convert.ToInt32(Console.ReadLine());
if (itemtype == 1)
{
switch (ordertype)
{
case 1:
orderitems = "Idly";
itemcost = idly;
break;
case 2:
orderitems = "Dosa";
itemcost = dosa;
break;
case 3:
orderitems = "Vada";
itemcost = vada;
break;
case 4:
orderitems = "Puri";
itemcost = puri;
break;
default:
Console.WriteLine("Choose a valid item");
break;
}
}
else if (itemtype == 2)
{
switch (ordertype)
{
case 1:
orderitems = "Plate Meals";
itemcost = pmeals;
break;
case 2:
orderitems = "Full Meals";
itemcost = fmeals;
break;
case 3:
orderitems = "Chicken Biryani";
itemcost = cbiryani;
break;
case 4:
orderitems = "Mutton Biryani";
itemcost = mbiryani;
break;
default:
Console.WriteLine("Choose a valid item");
break;
}
}
else if (itemtype == 3)
{
switch (ordertype)
{
case 1:
orderitems = "Burger";
itemcost = burger;
break;
case 2:
orderitems = "Pizza";
itemcost = pizza;
break;
case 3:
orderitems = "Momos";
itemcost = momos;
break;
case 4:
orderitems = "Sandwich";
itemcost = sandwich;
break;
default:
Console.WriteLine("Choose a valid item");
break;
}
}
else if (itemtype == 4)
{
switch (ordertype)
{
case 1:
orderitems = "Milk Shakes";
itemcost = milkshake;
break;
case 2:
orderitems = "Sprite";
itemcost = sprite;
break;
case 3:
orderitems = "Coke";
itemcost = coke;
break;
case 4:
orderitems = "Pepsi";
itemcost = pepsi;
break;
default:
Console.WriteLine("Choose a valid item");
break;
}
}
if (itemtype > 0 && itemtype < 5)
{
Console.WriteLine("You choose " + orderitems);
allitems = orderitems +"\t"+ itemcost+ "\n" + allitems;
totalcost = itemcost + totalcost;
Console.WriteLine(allitems);
}
}
Console.WriteLine("Do you want to continue (y/n): ");
cont = Convert.ToChar(Console.ReadLine());
} while (cont == 'y');
Console.WriteLine("Your Bill is " + totalcost);
Console.WriteLine("Do you want to add any tip");
tip = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Your ordered items : ");
Console.WriteLine("\n"+allitems);
Console.WriteLine("=========");
Console.WriteLine("Total :"+totalcost);
Console.WriteLine("Tip :"+tip);
bill = totalcost + tip;
Console.WriteLine("Total bill :" + bill);
Console.ReadLine();
}
}
}
Tags:
projects