Exercise – Create arrays and foreach loops
In this exercise, you’ll review the Starter project code and then begin updating the application. Your first coding task will be creating the arrays that hold student exam scores. Once your application data is available in arrays, you’ll begin working on a foreach
loop that can be used to sum student grades. The detailed tasks that you’ll complete during this exercise are:
- Code review: review the contents of the Program.cs file.
- Arrays: Create the arrays that store each student’s assignment scores.
- Iteration: Create a
foreach
loop that can be used to sum Sophia’s assignment grades. - Calculate and display Sophia’s average assignment grade.
- Verification test: perform a verification test for the code that you’ve developed in this exercise.
Important
You need to have completed the Setup instructions in the previous unit, Prepare, before you begin this Exercise.
Review the contents of the Program.cs file
In this task, you’ll review the code that’s provided as a Starter project for this module. The Program.cs file contains the initial version of the student grading application that you’ll be updating.
- Ensure that you have the GuidedProject folder open in Visual Studio Code.The Prepare unit (the previous unit in this module) includes a Setup section for this Guided project module. The Setup section describes the process for downloading your initial code and opening the project folder Visual Studio Code. If necessary, go back and follow the Setup instructions.
- In the Visual Studio Code EXPLORER panel, expand the Starter folder, then select Program.cs.When you select the Program.cs file, the file contents will open in the main Editor area to the right of the EXPLORER panel.If the EXPLORER panel isn’t open, you can open it using the Activity Bar on the far-left side of the Visual Studio Code window. The EXPLORER button is the topmost icon on the Activity Bar.
- Take a few minutes to review the code in the Program.cs file.
- Notice that the top portion of your code begins with a
Using
statement and a list of variable declarations.
microsoft windows server certification training courses malaysia