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

sukis111 2008-11-14 12:16:31
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 = "";
}
}
}
...全文
148 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
y63964632 2008-11-14
  • 打赏
  • 举报
回复
问题不太清楚~帮顶下
编程有钱人了 2008-11-14
  • 打赏
  • 举报
回复
0.8m;
不用“m”吧

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧