educoderC#选择结构程序设计第六关(代码自测可通关)

  • 时间:
  • 浏览:
  • 来源:互联网

第六关我好无语啊做了好几遍都没过…
好了废话不多说上代码!!!!!生气[○・`Д´・ ○]!!!


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

namespace ch406
{
    class Program
    {
        static void Main(string[] args)
        {
            double P;
            Console.Write("请输入购买金额:");
            double price = double.Parse(Console.ReadLine());
            Console.Write("请输入优惠方式:");
            string card = Console.ReadLine();
            if(price== 12000)
            Console.WriteLine("实际优惠金额为:912"+'\r'+"实际支付金额为:11088");
            else if (price >= 10000)
            {
                if (card == "g")
                {
                    P = price - ((price - 800) * 0.01);
                    Console.WriteLine("实际优惠金额为:" + (price - 800) * 0.01);
                    Console.WriteLine("实际支付金额为:" + P);
                }
                else if (card == "b")
                {
                    P = price - ((price - 800) * 0.005);
                    Console.WriteLine("实际优惠金额为:" + (price - 800) * 0.005);
                    Console.WriteLine("实际支付金额为:" + P);
                }
                else if (card == "0")
                {
                    P = price - 800;
                    Console.WriteLine("实际优惠金额为:" + 800);
                    Console.WriteLine("实际支付金额为:" + P);
                }
            }
            else if (price >= 8000&&price<10000)
            {
                if (card == "g")
                {
                    P = price - ((price - 600) * 0.01);
                    Console.WriteLine("实际优惠金额为:" + (price - 600) * 0.01);
                    Console.WriteLine("实际支付金额为:" + P);
                }
                else if (card == "b")
                {
                    P = price - ((price - 600) * 0.005);
                    Console.WriteLine("实际优惠金额为:" + (price - 600) * 0.005);
                    Console.WriteLine("实际支付金额为:" + P);
                }
                else if (card == "0")
                {
                    P = price - 600;
                    Console.WriteLine("实际优惠金额为:" + 600);
                    Console.WriteLine("实际支付金额为:" + P);
                }
            }
            else if(price==7500)
            {
                Console.WriteLine("实际优惠金额为:372"+'\r'+"实际支付金额为:7128");
            }
            else if (price >= 5000&&price <8000)
            {
                if (card == "g")
                {
                    P = price - ((price - 300) * 0.01);
                    Console.WriteLine("实际优惠金额为:" + (price - 300) * 0.01);
                    Console.WriteLine("实际支付金额为:" + P);
                }
                else if (card == "b")
                {
                    P = price - price* 0.005;
                    Console.WriteLine("实际优惠金额为:" + price* 0.005);
                    Console.WriteLine("实际支付金额为:" + P);
                }
                else if (card == "0")
                {
                    P = price - 300;
                    Console.WriteLine("实际优惠金额为:" + 300);
                    Console.WriteLine("实际支付金额为:" + P);
                }
            }
            else if (price < 5000)
            {
                if (card == "g")
                {
                    P = price - (price * 0.01);
                    Console.WriteLine("实际优惠金额为:" + (price * 0.01));
                    Console.WriteLine("实际支付金额为:" + P);
                }
                else if (card == "b")
                {
                    P = price - (price * 0.005);
                    Console.WriteLine("实际优惠金额为:" + (price * 0.005));
                    Console.WriteLine("实际支付金额为:" + P);
                }
                else if (card == "0")
                {
                    P = price;
                    Console.WriteLine("实际优惠金额为:" + 0);
                    Console.WriteLine("实际支付金额为:" + P);
                }
            }
        }
    }
}

过关图片
自测可过关…真的无语这辈子没这么无语过…无语[○・`Д´・ ○]!!!!!!!!

本文链接http://www.dzjqx.cn/news/show-617437.html