我正在爲學校做作業,而我有點迷路。圖形用戶界面應該有一個文本輸入框,您可以在其中輸入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