C#面向对象程序设计题目 在线等

2025-02-24 21:40:28
推荐回答(3个)
回答1:

请参考下面的类:

public class person {
string str1 = "超标", str2 = "标准", str3 = "偏廋";
public decimal height { get; set;}
public decimal weight { get; set; }
public bool male { get; set; }

public string Result(){
decimal dt = 0;
if(this.male) {
dt = (this.weight - (this.height - 105))/ this.weight;
}
else {
dt = (this.weight - (this.height - 110))/ this.weight;
}
if( dt > 0.1) return str1; else if (dt < -0.1) return str3; else return str2;
}
}

回答2:

先答你第二个题目吧。
一年20万元,年利率为7%。那如果一年还清就是20万加上20万乘以7%对吧。两年是乘14%。如果公式是这样的话。
做一个循环。
float a = 20; //货款数目
float b = 7/100; //利率
float c= 1; //每月可以还的钱。
float y =1; //年
while(!((c*12*y)>=(a+a*y*b)))
{
y++;
}
y就是最后还清所有钱所有的年了吧。。。

回答3:

分数太少