双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

本人是初学,想问一下一下一个计算打折的程序任何 实现

sukis111 sukis111 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}



private void button1_Click(object sender, EventArgs e)
{
decimal price, discount;
try
{

price = Convert.ToDecimal(Input.Text);
if (price >= 2000)
{
discount = price * 0.8m;
}
else if (price >= 1000 && price < 2000)
{
discount = price * 0.85m;
}
else if (price >= 500 && price < 1000)
{
discount = price * 0.9m;
}
else if (price >= 100 && price < 500)
{
discount = price * 0.95m;
}

discount = Convert.ToDecimal(....);//这里不太会定义
if (discount >= 0)
{
result.Text = String.Format("{0:C}", discount);
}
else
result.Text = "请输入整数";
}
catch
{
result.Text = "输入有错,请重输!";
}
}

private void button3_Click(object sender, EventArgs e)
{
this.Hide();
Program.f2.Show();
}

private void button2_Click(object sender, EventArgs e)
{
Input.Text = "";
result.Text = "";
}
}
}
...全文
评论 2
收藏 已收藏
分享
返回顶部
sukis111
C# 111,129 成员 642,540 内容