c#编程,麻烦高手指点写一下程序!!!!!! 急用 !!!!!!!!

2024-11-04 13:38:58
推荐回答(2个)
回答1:

public Double print(int num)
{
Double price=0;
if(num<仿源=100)
{
price =Convert.ToDouble( num * 0.5);
return price;
}
price = Convert.ToDouble(100 * 0.5 + (num - 100) * 0.3);
return price;
}

在你备野态脊银按纽下面调用这个方法
label1.Text= print(Convert.ToInt32(textBox1.Text)).ToString();

回答2:

public static void main(String[] args){
int num=Integer.parse(Console.ReadLine());
int rest=num-100;
int sum=0.5*num+(rest>0?rest:0)*(0.5-0.3);
Console.WriteLine(sum);
}