如何解决以下问题的逻辑 [英] how to logic for the following problem

查看:77
本文介绍了如何解决以下问题的逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

抱歉我的英语很差。

我在UI处输入重量,为0.500

然后我得到40的金额。

重量后0.500,意味着从0.501它应该给我结果数量为55,最高为1.000。

从重量1.001它应该返回我的金额为110到1.500

明智的,



重量金额

为1.001至1.500 110

为1.501至2.000 165

for 2.001 to 3.000 220



等等





我如何在c#

sorry for my poor english.
I input weight at UI, as 0.500
then i get amount as 40.
after weight 0.500, means from 0.501 it should give me result Amount as 55 for upto the weight 1.000.
From weight 1.001 it should return me amount as 110 upto 1.500
like wise,

weight Amount
for 1.001 to 1.500 110
for 1.501 to 2.000 165
for 2.001 to 3.000 220

and so on


How can i implement it in c#

推荐答案

中实现它你好,

请试试这个。

Hello,
Plz try this.
    decimal amt=0;
    decimal weight=Convert.ToDecimal(txtWeight.Text);
    if(weight<=0.500)
       amt=40;
    else if (weight>=0.501 && weight<=1.000)
       amt=55;
    else if (weight>=1.001 && weight<=1.500)
       amt=110;
    else if (weight>=1.501 && weight<=2.000)
       amt=165;
    else if (weight>=2.001 && weight<=3.000)
       amt=220;

//use amt variable in your further code


这篇关于如何解决以下问题的逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆