[Update] Received help on my assignment so I thought I will show you guys what I did before I turn it in.

This is the original post Where I didn't know how to store the leading hitter and have it change when a hitter with a greater count was entered.

Thanks to everyone for the help and input.

This is what my final code looks like.

public Form1() { InitializeComponent(); }

 const decimal tier1 = 17500; const decimal tier2 = 20000; const decimal tier3 = 22500; const decimal tier4 = 25000; string leadingHitter; decimal leadingSalary = 0; decimal leadingHits = 0; private void calculateBttn_Click(object sender, EventArgs e) { //Variables decimal seasonHits = 0; decimal salary = 0; decimal singleAwardBonus = 0; decimal doubleAwardBonus = 0; string playerName; //Process seasonHits = decimal.Parse(seasonHitsTxtBox.Text); playerName = nameTxtBox.Text; //if statements if (seasonHits >= 0 && seasonHits <= 49) { salary = seasonHits * tier1; tierDsplyLbl.Text = "Tier 1"; } else if (seasonHits >= 50 && seasonHits <= 99) { salary = seasonHits * tier2; tierDsplyLbl.Text = "Tier 2"; } else if (seasonHits >= 100 && seasonHits <= 149 ) { salary = seasonHits * tier3; tierDsplyLbl.Text = "Tier 3"; } else if (seasonHits >= 150 ) { salary = seasonHits * tier4; tierDsplyLbl.Text = "Tier 4"; } if (allStarCheckBox.Checked && mvpCheckBox.Checked)//Give bonus for AllStar and MVP selection { doubleAwardBonus = salary * .25m; salary = salary + doubleAwardBonus; } else if (allStarCheckBox.Checked || mvpCheckBox.Checked)//Give bonus for AllStar or MVP Selection { singleAwardBonus = salary * .20m; salary = salary + singleAwardBonus; } if (seasonHits > leadingHits)//Determines the Leading hitter { leadingHits = seasonHits; leadingHitter = playerName; leadingSalary = salary; } //Output salaryDsplyLbl.Text = salary.ToString("c"); salaryGroupDsplyLbl.Text = leadingSalary.ToString("c"); nameGroupDsplyLbl.Text = leadingHitter; hitsGroupDsplyLbl.Text = leadingHits.ToString("0"); nameDsplyLbl.Text = playerName; hitsDsplyLbl.Text = seasonHits.ToString("0"); //Clears Text boxes and Checkboxes nameTxtBox.Text = ""; seasonHitsTxtBox.Text = ""; allStarCheckBox.Checked = false; mvpCheckBox.Checked = false; } private void clearBttn_Click(object sender, EventArgs e) { salaryDsplyLbl.Text = ""; salaryGroupDsplyLbl.Text = ""; nameGroupDsplyLbl.Text = ""; hitsGroupDsplyLbl.Text = ""; nameTxtBox.Text = ""; seasonHitsTxtBox.Text = ""; nameDsplyLbl.Text = ""; hitsDsplyLbl.Text = ""; } private void exitBttn_Click(object sender, EventArgs e) { Application.Exit(); } } 

by dmf055 via /r/csharp

Leave a Reply