Introduction

Completed

It's common for developers to begin a project by developing the features that import or generate application data. Once your application has access to the data it depends on, you can begin developing the features that process data and generate reports.

Suppose you're a developer who likes to support the local community. You and some of your friends started a business that helps find new homes for stray or abandoned cats and dogs. Your business started off small, with just a couple of strays, but it's starting to grow. You want to create an application that will help you match the animals in your care with people looking for a pet. You've found that it's important to have a detailed description of the animals to share with potential owners. In addition, being able to describe the personality of the dog or cat makes them more appealing to potential owners. You decide to create an application that helps you manage information about the dogs and cats you're caring for.

This module guides you through the process of developing the data-centric features of the Contoso Pets application. You'll use selection and iteration statements to create sample data, list the animals in your care, and add new animals to your business. Throughout the application, you'll use variables and expressions to control the execution of code branches. You will also ensure that variables are scoped appropriately.

The application you develop will:

  • Add predefined sample data to the pets array.
  • Iterate a "menu options and user selection" code block to establish the outer loop of your application.
  • Implement code branches corresponding to the user's menu selections.
  • Display all the information contained in the array used to store pet data (based on user's menu selection).
  • Iterate an "add new animal information" code block that enables the user to add one or more new animals to the pets array (based on user's menu selection).

By the end of this module, you will be able to develop code that combines selection and iteration statements to achieve your application design goals.

Note

This is a guided project module where you’ll complete an end-to-end project by following step-by-step instructions.

Learning Objectives

In this module, you'll practice how to:

  • Use Visual Studio Code to develop a C# console application that uses a combination of selection and iteration statements to implement logical workflows.
  • Evaluate the underlying conditions in your application and make an informed decision between selection statement options.
  • Evaluate the underlying conditions in your application and make an informed decision between iteration statement options.
  • Scope variables at an appropriate level within an application.

Prerequisites

  • Experience using Visual Studio Code to develop, build, and run C# console applications that include console I/O and access methods of .NET classes.
  • Experience using C# code to evaluate conditional expressions and manage variable scope inside and outside of code blocks.
  • Experience using if-elseif-else and switch-case statements in C# to match a variable or expression against several possible outcomes.
  • Experience using foreach, for, do, and while statements in C# to loop through a block of code and access elements of array variables.