C#--if else基础训练输入参观的月份,输出实行的淡季或旺季票价

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test2
{
    class Program
    {
        static void Main(string[] args)
        {
 
           int month;  // 参观的月份
        
            Console.WriteLine("请输入你参观故宫的月份:");
            month = int.Parse(Console.ReadLine());

            if ((month >= 11 && month <= 12) || (month >= 1 && month <= 3))
            {
                Console.WriteLine("现在是淡季,门票全价为40元,学生20元。");
             }
             else if ((month >= 4 && month <= 10))
            {
                Console.WriteLine("现在是旺季,门票全价为60元,学生20元。");
            }
            else
            {
                Console.WriteLine("对不起,你输入的月份不正确!");
            }
            Console.ReadLine();
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test3
{
    class Program
    {
        static void Main(string[] args)
        {
            String type;
            int month;  // 参观的月份
            Console.WriteLine("请输入你是属于哪类参观者:\n1-1.2米以下儿童\n2-大中小学生\n3-离休人员\n4-老年人\n5-其他");
            type = Console.ReadLine();

            Console.WriteLine("请输入你参观故宫的月份:");
            month = int.Parse(Console.ReadLine());
           
            // 根据选择的类型,输出享受的优惠
            switch (type)
            {
                case "1":
                case "3":
                    Console.WriteLine("可以享受免票优惠!");
                    break;
                case "2":
                    Console.WriteLine("优惠后票价20元!");
                    break;
                case "4":
                    Console.WriteLine("可以享受半价优惠!");
                    break;
                default:
                    Console.WriteLine("不能享受优惠!");
                    break;
            }

            if ((month >= 11 && month <= 12) || (month >= 1 && month <= 3))
            {
                Console.WriteLine("现在是淡季,门票全价为40元,学生20元。");
            }
            else if ((month >= 4 && month <= 10))
            {
                Console.WriteLine("现在是旺季,门票全价为60元,学生20元。");
            }
            else
            {
                Console.WriteLine("对不起,你输入的月份不正确!");
            }
            Console.ReadLine();
        }
        
    }
}

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值