匿名通过本文主要向大家介绍了C#小程序等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
实现效果:
屏幕出现提示:1、小杯3元;2、中杯4元;3、大杯5元,请输入对应数字选择...
用户输入数字则提示对应的结果:小杯,请支付3元;输入错误则默认中杯
下面是源代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleManyHellos
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("1=小杯3块,2=中杯4块,3=大杯5块");
Console.Write("你的选择?");
string s = Console.ReadLine();
int n = int.Parse(s);
switch (n)
{
case 1:
Console.WriteLine("小杯,请支付3块钱;");
break;
case 2:
Console.WriteLine("中杯,请支付4块钱;");
break;
case 3:
Console.WriteLine("大杯,请支付5块钱;");
break;
default:
Console.WriteLine("默认中杯,请付款4块钱;");
break;
}
Console.WriteLine("谢谢使用,祝您用餐愉快!");
}
}
}命令行效果截图:
![[C#小程序]命令行小程序之你要买大杯小杯还是中杯的实现代码 [C#小程序]命令行小程序之你要买大杯小杯还是中杯的实现代码](/UpFiles/2018/11/30/1490332291495696.jpg)
以上就是[C#小程序]命令行小程序之你要买大杯小杯还是中杯的实现代码的详细内容,更多请关注微课江湖其它相关文章!

