购物打折与Delphi的Case<表达式> of 语句
procedure TForm1.Button1Click(Sender: TObject);
var
s,t:real; //s为折扣后金额,t为未打折金额
m:integer; //m为t的截取整数
begin
t:=strToFloat(edit1.text);
m:=trunc(t);
case (m div 100) of //m整除100的结果属于下列范围:
0:s:=t;
1,2:s:=t*(1-5/100);
3,4:s:=t*(1-10/100);
5,6,7,8,9:s:=t*(1-15/100);
else
s:=t*(1-20/100);
end;
edit2.Text:=FloatTostr(s);
end;
转载于:https://blog.51cto.com/tzlin/592472
最后
以上就是帅气网络最近收集整理的关于购物打折与Delphi的Case<表达式> of 语句(附:源码)的全部内容,更多相关购物打折与Delphi的Case<表达式>内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复