1
好我的問題更簡單,這次我已經重做我以前的問題的代碼。現在我試圖弄清楚爲什麼我的每月賬單沒有增加。它應該在方程中增加。我嘗試調試代碼,但沒有發現ArrayMonths數組是否循環。我如何獲得數組循環,以便公式增加,如每月付款
private void CalculateButton_Click(object sender, EventArgs e)
{
string[] ArrayModel ={"CAMERO","IMPALA","TAHOE","SILVERADO","MUSTANG","TAURUS","EXPEDITION","F150",
"CAMERY","COROLLA","HIGHLANDER","TUNDRA","CHALLENGER","DART","DURANGO","RAM"};
double[] ArrayPrice ={33809,23300,49601,33383, 40585,32500,36245,46905,
48050,32560,42580,47530, 27995,20150,39750,45620};
double[] ArrayMonths = { 36, 48, 60, 72 };
string Model = ModelBox.Text.ToUpper();
double InterestRate = 0, TotalIntrst, MonthlyBill, Multiplier, Year, MaxYear = 4;
string UsrModelVehicle = ModelBox.Text.ToUpper();
double UsrScrInpt = Convert.ToDouble(CreditScoreBox.Text);
{
if (UsrScrInpt <= 450)
{
for (int x = 0; x < ArrayModel.Length; ++x)
{
if (Model == ArrayModel[x])
{
foreach (double Months in ArrayDuration)
{
ArrayModel[x] = Convert.ToString(ArrayLoan[x]);
InterestRate = 0.12;
TotalIntrst = InterestRate/1200;
MonthlyBill = ArrayLoan[x] * TotalIntrst/(1 - (Math.Pow(1/(1 + TotalIntrst), Months)));
UserMonthlyPayLabel.Text += string.Format("{0:C2}\n", MonthlyBill);
UserInterestLabel.Text = string.Format("{0:P2}", InterestRate);
InterestLabel.Text = string.Format("Interest");
PayNumbersLabel.Text = string.Format("36\n48\n60\n72\n");
確定型號從文本框是數組中? –
ArrayMonths [y]是我試圖循環以提高月數,這將增加* MonthlyBill *,然後反過來給我我的名單。我認爲。我希望。 – Brandonl29
你是什麼意思列表不增加?你期望看到什麼?您是否希望每次迭代for循環都更新標籤文本?因爲這不是一個很好的實現。 –