這篇文章主要介紹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#是一個簡單、通用、面向對象的編程語言,它由微軟Microsoft開發,繼承了C和C++強大功能,并且去掉了一些它們的復雜特性,C#綜合了VB簡單的可視化操作和C++的高運行效率,以其強大的操作能力、優雅的語法風格、創新的語言特性和便捷的面向組件編程從而成為.NET開發的首選語言,但它不適用于編寫時間急迫或性能非常高的代碼,因為C#缺乏性能極高的應用程序所需要的關鍵功能。
以上是“C#如何實現一個控制臺的點餐系統”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。