回复 4楼 ZWYyj
{
string grade = Convert.ToString(textBox1.Text.Trim());
string name = Convert.ToString(textBox2.Text.Trim());
double sql = Convert.ToDouble(textBox3.Text.Trim());
double english = Convert.ToDouble(textBox4.Text.Trim());
double csharp = Convert.ToDouble(textBox5.Text.Trim());
student h = new student(
grade,name,sql,english,csharp);
label6.Text = Convert.ToString(h.zongfen(english, csharp,sql));
}
class student
{
string grade;
string name;
double sql;
double english;
double csharp,pj;
public student(string grade, string name, double sql, double english, double csharp)
{
this.grade = grade;
this.name = name;
this.sql = sql;
this.english = english;
this.csharp = csharp;
}
public double zongfen(double english, double csharp,double sql)
{
return english + csharp+sql ;
}
public double average(double english, double csharp,double sql)
{
return pj = (english + csharp+sql) / 3;
}
public string dengji(double english, double csharp, double sql)
{
if (pj >= 85 && english > 75 && csharp > 75 && sql > 75)
{
return "优秀";
}
else if (pj >= 75 && english > 70 && csharp > 70 && sql > 70)
{
return "良好";
}
else
{
return "合格";
}
}
}
private void button2_Click(object sender, EventArgs e)
{
string grade = Convert.ToString(textBox1.Text.Trim());
string name = Convert.ToString(textBox2.Text.Trim());
double
sql = Convert.ToDouble(textBox3.Text.Trim());
double english = Convert.ToDouble(textBox4.Text.Trim());
double csharp = Convert.ToDouble(textBox5.Text.Trim());
student h = new student(grade, name, sql, english, csharp);
label7.Text = Convert.ToString(h.average(english, csharp,sql));
}
private void button3_Click(object sender, EventArgs e)
{
string grade = Convert.ToString(textBox1.Text.Trim());
string name = Convert.ToString(textBox2.Text.Trim());
double
sql = Convert.ToDouble(textBox3.Text.Trim());
double english = Convert.ToDouble(textBox4.Text.Trim());
double csharp = Convert.ToDouble(textBox5.Text.Trim());
student h = new student(grade, name, sql, english, csharp);
label8.Text = Convert.ToString(h.dengji(english, csharp,sql));
}
}
}
为什么无论我输入多少分成绩都是显示为合格的?显示不了优秀或良好的,到底哪里出错了?求大神指教!!!感激不尽!!