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)
First, this is a school assignment however I only need help with the specific issue in the title. I will paste the instruction regarding this specific task. "This project will contain while loops to step through the dormData Array to find the selected dorm and its price and to step through the meal Data Array to find the selected meal plan and price."
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[] 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" };
These are my arrays, the DormCostArray correalates with the DormListArray and the same for the MealPlanArray. If I want "Allen Hall" from the DormListArray, I want to make a while loop that will run through the DormCostArray until it gets to 1500. Both of these are the first elements in their arrays, but like I said I do not know how to make a loop to make it work. I can provide the entirety of the prompt as well as my code if needed but I just do not know where to go from here and don't have much experience reaching out to people on the interenet for help
37 replies