期中作业(三)

#编码

Console.WriteLine("游戏币支付");

 Console.WriteLine(@"游戏类型:

 1.牌类 2.休闲竞技类");

string xuanzhe = Console.ReadLine();

 int zhekou = 0;

double money = 0;

switch (xuanzhe)

 {

case "1":

 Console.WriteLine("游戏时长");

 string str_time = Console.ReadLine();

 int time = Convert.ToInt32(str_time);

if (time < 0)

 {

 Console.WriteLine("时间应该大于0");

 break;

 }

 else

if (time > 10)

 {

zhekou += 5;

 money = 10 * time * 0.5;

 }

else

{

zhekou += 8; money = 10 * time * zhekou * 0.1;

 }

 Console.WriteLine("你在玩牌类,时长:{0},折扣:{1},你要支付的金额是:{2}游戏币", time, zhekou, money);

 break;

 case "2":

 Console.WriteLine("游戏时长");

string str_t = Console.ReadLine();

 int t = Convert.ToInt32(str_t);

if (t < 0)

 {

Console.WriteLine("时间应该大于0");

 break;

 }

 else if (t> 10) { zhekou += 5; money = 20 * t * zhekou * 0.1;

 }

else

 {

zhekou += 8;

money = 20 * t * zhekou * 0.1;

 }

Console.WriteLine("你在玩休闲竞技类,时长:{0},折扣:{1},你要支付的金额是:{2}游戏币", t, zhekou, money);

 break;

default:

 Console.WriteLine("无此选项,错误");

 break;

 }

 Console.ReadKey();

 }

 }

 }

#效果

你可能感兴趣的:(期中作业(三))