求助:为什么一精确到分程序就不准了
[local]1[/local]图片是运行结果
如下代码:
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace lingqian
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double a, b, c, count = 0;
a = double.Parse(textBox1.Text);
b = double.Parse(textBox2.Text);
textBox3.Text = (b - a).ToString();
c = double.Parse(textBox3.Text);
while (c >= 100)
{
c -= 100;
count++;
}
textBox4.Text = count.ToString();
int zx = 0;
while(c<100 && c>=50)
{
c -= 50;
zx++;
}
textBox5.Text =zx .ToString();
int zc = 0;
while (c < 50 && c >= 20)
{
c -= 20;
zc++;
}
textBox6.Text = zc.ToString();
int asd = 0;
while (c < 20 && c >= 10)
{
c -= 10;
asd++;
}
textBox7.Text = asd.ToString();
int ad = 0;
while (c < 10 && c >= 5)
{
c -= 5;
ad++;
}
textBox8.Text = ad.ToString();
int vb = 0;
while (c < 5 && c >= 2)
{
c -= 2;
vb++;
}
textBox9.Text = vb.ToString();
int bn = 0;
while (c < 2 && c >= 1)
{
c -= 1;
bn++;
}
textBox10.Text = bn.ToString();
int mn = 0;
while (c < 1 && c >= 0.5)
{
c -= 0.5;
mn++;
}
textBox11.Text = mn.ToString();
int ty = 0;
while (c < 0.5 && c >= 0.2)
{
c -= 0.2;
ty++;
}
textBox12.Text = ty.ToString();
int rt = 0;
while (c < 0.2 && c >= 0.1)
{
c -= 0.1;
rt++;
}
textBox13.Text = rt.ToString();
int yu = 0;
while (c < 0.1 && c >= 0.05)
{
c -= 0.05;
yu++;
}
textBox14.Text = yu.ToString();
int ui = 0;
while (c < 0.05 && c >= 0.02)
{
c -= 0.02;
ui++;
}
textBox15.Text = ui.ToString();
int oi = 0;
while (c < 0.02 && c >= 0.01)
{
c -= 0.01;
oi++;
}
textBox16.Text = oi.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
label4.Text = "";
}
}
}