So I'm almost 100% certain I've done something wrong simply due to the inefficiency of what I've written, I'm entirely a novice to coding and am working on an assignment for my introductory programming course. The only way I could think to display the input from 4 check boxes was to go down 16 different branches to cover every possible input option, is there any simpler or quicker way to show the results on a listbox? This project is for a mock cruise invoice
//Onboard services expense clarification//
int finedining;
finedining = int.Parse("200");
int fitnesstrainer;
fitnesstrainer = int.Parse("50");
decimal excursions;
excursions = decimal.Parse("399.9");
decimal airporttransfer;
airporttransfer = decimal.Parse("45.5");
decimal noservices;
noservices = decimal.Parse("0.00");
//Check Box Data//
if (diningCheckBox.Checked && !fitnessCheckBox.Checked && !excursionsCheckBox.Checked && !airportCheckBox.Checked)
{
titlesListBox.Items.Add("Fine Dining");
valueListBox.Items.Add(finedining);
}
else if (diningCheckBox.Checked && fitnessCheckBox.Checked && !excursionsCheckBox.Checked && !airportCheckBox.Checked)
{
titlesListBox.Items.Add("Fine Dining, Fitness Trainer");
valueListBox.Items.Add(finedining + fitnesstrainer);
}
else if (diningCheckBox.Checked && fitnessCheckBox.Checked && excursionsCheckBox.Checked && !airportCheckBox.Checked)
{
titlesListBox.Items.Add("Fine Dining, Fitness Trainer, Excursions");
valueListBox.Items.Add(finedining + fitnesstrainer + excursions);
}
else if (diningCheckBox.Checked && fitnessCheckBox.Checked && excursionsCheckBox.Checked && airportCheckBox.Checked)
{
titlesListBox.Items.Add("Fine Dining, Fitness Trainer, Excursions, Airport Transfer");
valueListBox.Items.Add(finedining + fitnesstrainer + excursions + airporttransfer);
}
else if (diningCheckBox.Checked && !fitnessCheckBox.Checked && excursionsCheckBox.Checked && airportCheckBox.Checked)
{
titlesListBox.Items.Add("Fine Dining, Excursions, Airport Transfer");
valueListBox.Items.Add(finedining + excursions + airporttransfer);
}
else if (diningCheckBox.Checked && fitnessCheckBox.Checked && !excursionsCheckBox.Checked && airportCheckBox.Checked)
{
titlesListBox.Items.Add("Fine Dining, Fitness Trainer, Airport Transfer");
valueListBox.Items.Add(finedining + fitnesstrainer + airporttransfer);
}
else if (diningCheckBox.Checked && !fitnessCheckBox.Checked && !excursionsCheckBox.Checked && airportCheckBox.Checked)
{
titlesListBox.Items.Add("Fine Dining, Airport Transfer");
valueListBox.Items.Add(finedining + airporttransfer);
}
else if (diningCheckBox.Checked && !fitnessCheckBox.Checked && excursionsCheckBox.Checked && !airportCheckBox.Checked)
{
titlesListBox.Items.Add("Fine Dining, Excursions");
valueListBox.Items.Add(finedining + excursions);
}
else if (!diningCheckBox.Checked && fitnessCheckBox.Checked && excursionsCheckBox.Checked && airportCheckBox.Checked)
{
titlesListBox.Items.Add("Fitness Trainer, Excursions, Airport Transfer");
valueListBox.Items.Add(fitnesstrainer + excursions + airporttransfer);
}
else if (!diningCheckBox.Checked && fitnessCheckBox.Checked && excursionsCheckBox.Checked && !airportCheckBox.Checked)
{
titlesListBox.Items.Add("Fitness Trainer, Excursions");
valueListBox.Items.Add(fitnesstrainer + excursions);
}
else if (!diningCheckBox.Checked && fitnessCheckBox.Checked && !excursionsCheckBox.Checked && airportCheckBox.Checked)
{
titlesListBox.Items.Add("Fitness Trainer, Airport Transfer");
valueListBox.Items.Add(fitnesstrainer + airporttransfer);
}
else if (!diningCheckBox.Checked && fitnessCheckBox.Checked && !excursionsCheckBox.Checked && !airportCheckBox.Checked)
{
titlesListBox.Items.Add("Fitness Trainer");
valueListBox.Items.Add(fitnesstrainer);
}
else if (!diningCheckBox.Checked && !fitnessCheckBox.Checked && excursionsCheckBox.Checked && airportCheckBox.Checked)
{
titlesListBox.Items.Add("Excursions, Airport Transfer");
valueListBox.Items.Add(excursions + airporttransfer);
}
else if (!diningCheckBox.Checked && !fitnessCheckBox.Checked && excursionsCheckBox.Checked && !airportCheckBox.Checked)
{
titlesListBox.Items.Add("Excursions");
valueListBox.Items.Add(excursions);
}
else if (!diningCheckBox.Checked && !fitnessCheckBox.Checked && !excursionsCheckBox.Checked && airportCheckBox.Checked)
{
titlesListBox.Items.Add("Airport Transfer");
valueListBox.Items.Add(airporttransfer);
}
else if (!diningCheckBox.Checked && !fitnessCheckBox.Checked && !excursionsCheckBox.Checked && !airportCheckBox.Checked)
{
titlesListBox.Items.Add("No onboard services requested");
valueListBox.Items.Add(noservices);``
Click
handler for someOk
button? \$\endgroup\$