C#实现一个控制台的点餐系统
更新时间:2019年11月26日 17:14:52 作者:王梦翰
这篇文章主要为大家详细介绍了C#实现一个控制台的点餐系统,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了C#点餐系统的具体代码,供大家参考,具体内容如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 控制台操作尝试
{
class Program
{
static void Main(string[] args)
{
int price = 0;
Console.WriteLine("欢迎来吃饭");
Console.WriteLine("===================================================================");
Console.WriteLine("1.糖醋里脊 24元");
Console.WriteLine("2 红烧茄子 14元");
Console.WriteLine("3.千页豆腐 18元");
Console.WriteLine("4.蚂蚁上树 20元");
Console.WriteLine("5.红烧猪蹄 36元");
Console.WriteLine("6.宫保鸡丁 32元");
Console.WriteLine("===================================================================");
Console.WriteLine("请按菜品序号点餐,0号键结算");
Console.WriteLine("===================================================================");
while (true)
{
int index = int.Parse(Console.ReadLine());
if (index==1)
{
Console.WriteLine("您点的是糖醋里脊 24元");
price += 24;
}
if (index == 2)
{
Console.WriteLine("您点的是红烧茄子 14元");
price += 14;
}
if (index ==3)
{
Console.WriteLine("您点的是千页豆腐 18元");
price += 18;
}
if (index == 4)
{
Console.WriteLine("您点的是蚂蚁上树 20元");
price += 20;
}
if (index == 5)
{
Console.WriteLine("您点的是红烧猪蹄 36元");
price += 36;
}
if (index == 6)
{
Console.WriteLine("您点的是宫保鸡丁 32元");
price += 32;
}
if (index ==0)
{
Console.WriteLine("您总共消费{0}元",price);
}
}
//Console.ReadLine();
}
}
}
效果图:

更多学习资料请关注专题《管理系统开发》。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
相关文章
C#线程 BeginInvoke和EndInvoke使用方法
本文开始C#线程系列讲座之一,即BeginInvoke和EndInvoke的使用方法,需要的朋友可以参考下2013-05-05
C# Windows API应用之基于FlashWindowEx实现窗口闪烁的方法
这篇文章主要介绍了C# Windows API应用之基于FlashWindowEx实现窗口闪烁的方法,结合实例形式分析了Windows API函数FlashWindowEx的功能、定义及实现窗口闪烁的相关技巧,需要的朋友可以参考下2016-08-08


最新评论