我正在为学校做作业,而我有点迷路。图形用户界面应该有一个文本输入框,您可以在其中输入SAT分数,然后将该分数转换为ACT分数,并将该ACT分数显示在文本框中,然后说明该分数在另一个文本框中是否足够高。有关GUI的更多问题
根据SAT是否落入这些数字,将SAT分数转换为ACT分数。我不知道怎么写,找出其中SAT成绩输入落入在ACT,并把它显示到文本框条款...
SAT score > 1600 = ACT score 37 (high enough)
SAT score from 1560-1590 = ACT score 36 (high enough)
SAT score from 1510-1550 = ACT score 35 (high enough)
SAT score from 1460-1500 = ACT score 34 (high enough)
SAT score from 1410-1450 = ACT score 33 (too low)
SAT score from 1360-1400 = ACT score 32 (too low)
SAT score < 1350 = ACT score 31 (too low)
同时,我们也必须写一个try/catch到确保输入了一个整数,而不是别的。我明白这一点。
这是我的代码到目前为止没有任何错误。
private void convertButton_Click(object sender, EventArgs e)
{
try
{
double satscore;
satscore = Convert.ToDouble(satScoreTextBox.Text);
}
catch
{
MessageBox.Show("Invalid input, value must be numeric");
satScoreTextBox.Focus();
satScoreTextBox.SelectAll();
}
}
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
谢谢,任何帮助表示赞赏!
所以你试图做转换呢?如果是这样,你尝试了什么(以及发生了什么,为什么它没有工作)?一个巨大的if/else if chain应该是最简单的选择,即使存在一些更灵活/优雅的解决方案。 – Servy 2013-04-23 20:27:11
我还没有尝试过,因为我不知道如何检查哪个范围的数字。我迷路了。迄今为止,我们没有任何实验室或作业。 – user2089370 2013-04-23 20:30:03
@OP StackOverflow不是一个家庭作业解决方案板。至少尝试一下自己,然后尝试发布。与教授或助教一起上课时间可能会更好。 – tyh 2013-04-23 20:31:30