我一直在研究一個我想做一個簡單計算的問題。我對C#很陌生,但我試圖學習。C#,在表單中實現單選按鈕來計算Nest Egg
基本上,如果給出四種不同的輸入,我必須節省多少資金:收入需求,稅率,預計回報率和每個時間段的收入。
我正在使用一組單選按鈕來選擇每個時間段的收入,基本上是每日,每週,每月,每年的收入。因此,單選按鈕選擇收入如何列爲價值,但我不確定如何將此部分的變量存入計算部分。我將提供一個代碼片段。
任何幫助將不勝感激,謝謝。
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
// Local variables
decimal income;
// Get the income, tax rate and rate of return.
income = decimal.Parse(incomeDesiredTextBox.Text);
// Determine pay period
if (true)
{
if (incomePerDayRadioButton.Checked)
{
decimal newIncome = income/365;
return;
}
else if (incomePerMonthRadioButton.Checked)
{
decimal newIncome = income/24;
return;
}
else if (incomePerWeekRadioButton.Checked)
{
decimal newIncome = income/52;
return;
}
else if (incomePerYearRadioButton.Checked)
{
decimal newIncome = income/1;
return;
}
}
}
private void calculateButton_Click(object sender, EventArgs e)
{
// Local variables
decimal income;
decimal newIncome;
decimal taxRate;
decimal rateOfReturn;
// Get the income, tax rate and rate of return.
income = decimal.Parse(incomeDesiredTextBox.Text);
taxRate = decimal.Parse(totalTaxesTextBox.Text);
rateOfReturn = decimal.Parse(rateOfReturnTextBox.Text);
//change rate of return to decimal format
var rateOfReturnPercentage = rateOfReturn/100;
// Calculate Nest Egg.
decimal taxedIncome = newIncome * taxRate;
}
![有效的XHTML(https://gyazo.com/b52272b73c9915f2c612793bf62f87fd)。 – Crawlersout
我已經包含了一個到目前爲止的形式看起來像Gyazo的鏈接。 – Crawlersout