Sytang
Sytang
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
i figured it out
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
that I do not understand
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
then just have a loop run through the second array the way that you said the run the first one
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
could I store the selected index position in a variable?
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
thats what im thinking, thats why i was having trouble wording the question
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
yeah
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
Ill see what I can come up with a report back before confusing myself further
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
because that seems to just give me the position of the first array instead of using a loop to find it
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
so would i need to recode where I use the selected index?
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
that makes a lot of sense, i didnt think of saving the index to a variable itself
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
both are the 3rd element
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
string[] dgDormListArray = { "Allen Hall", "Pike Hall", "Farthing Hall", "University Suites" };
string[] dgDormListArray = { "Allen Hall", "Pike Hall", "Farthing Hall", "University Suites" };
and
int[] dgDormCostArray = { 1500, 1600, 1800, 2500 };
int[] dgDormCostArray = { 1500, 1600, 1800, 2500 };
for example If I choose "Farthing Hall", have the loop check dgDormCostArray and iterate until it reaches 1800
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
so while the selected index is not found, have the loop check the other array until it finds the same position as the selected index in the first array
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
so essentially set a while loop that actually has nothing to do with positioning and only looks for the specific value I want
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
so I need to run the while loop as many times as the selected index is in the order of elements and have it stop on the same position for a separate array
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
im finding it really difficult to word this right
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
yeah
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
idk how to make it look right with the colors and all
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
namespace DanielGurr_FinalProject_10_5_2_
{
public partial class DG_MainForm : Form
{
int[] dgDormCostArray = { 1500, 1600, 1800, 2500 };
int[] dgMealPlanArray = { 600, 1200, 1700 };
string[] dgDormListArray = { "Allen Hall", "Pike Hall", "Farthing Hall", "University Suites" };
string[] dgMealPlanChoiceArray = { "7 meals per week", "14 meals per week", "Unlimited meals" };
int dgTotalPrice;
public DG_MainForm()
{
InitializeComponent();
}

private void DG_MainForm_Load(object sender, EventArgs e)
{
dgDormListBox.Items.Clear();
dgMealPlanListBox.Items.Clear();

for (int i = 0; i < dgDormListArray.Length; i++)
{
dgDormListBox.Items.Add(dgDormListArray[i].ToString());
}

for (int i = 0; i < dgMealPlanChoiceArray.Length; i++)
{
dgMealPlanListBox.Items.Add(dgMealPlanChoiceArray[i].ToString());
}
}

private void dgDisplayCostButton_Click(object sender, EventArgs e)
{
dgTotalPrice = 0;
dgTotalPrice = dgDormCostArray[dgDormListBox.SelectedIndex] + dgMealPlanArray[dgMealPlanListBox.SelectedIndex];

}
}
}
namespace DanielGurr_FinalProject_10_5_2_
{
public partial class DG_MainForm : Form
{
int[] dgDormCostArray = { 1500, 1600, 1800, 2500 };
int[] dgMealPlanArray = { 600, 1200, 1700 };
string[] dgDormListArray = { "Allen Hall", "Pike Hall", "Farthing Hall", "University Suites" };
string[] dgMealPlanChoiceArray = { "7 meals per week", "14 meals per week", "Unlimited meals" };
int dgTotalPrice;
public DG_MainForm()
{
InitializeComponent();
}

private void DG_MainForm_Load(object sender, EventArgs e)
{
dgDormListBox.Items.Clear();
dgMealPlanListBox.Items.Clear();

for (int i = 0; i < dgDormListArray.Length; i++)
{
dgDormListBox.Items.Add(dgDormListArray[i].ToString());
}

for (int i = 0; i < dgMealPlanChoiceArray.Length; i++)
{
dgMealPlanListBox.Items.Add(dgMealPlanChoiceArray[i].ToString());
}
}

private void dgDisplayCostButton_Click(object sender, EventArgs e)
{
dgTotalPrice = 0;
dgTotalPrice = dgDormCostArray[dgDormListBox.SelectedIndex] + dgMealPlanArray[dgMealPlanListBox.SelectedIndex];

}
}
}
37 replies
CC#
Created by Sytang on 12/3/2023 in #help
New to C# (How to use while loops to check through multiple arrays)
that was just to satisfy any errors and it does get the job done but I am required to use while loops in particular
37 replies