Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Microsoft CSharp Programming For The Absolute Beginner (2002) [eng].pdf
Скачиваний:
39
Добавлен:
16.08.2013
Размер:
15.71 Mб
Скачать

Chapter 2: Branching and Operators: The Math Game

Now that you know how to set up a basic C# program, you are ready to manipulate information in a more interesting way. In this chapter, you will learn several ways computers deal with information. You will also learn how to have computers appear to make decisions and how to generate random numbers, which are useful in a surprising number of situations. After reading this chapter, you will be able to:

Understand numeric data types.

Convert variables from one type to another.

Use if and switch statements to control branching behavior.

Create a random number.

Understand basic math and assignment operators.

The Math Game

As usual, you will learn all these elements in the context of a simple game. For this chapter, you will write a game that is great for kids in elementary school. Figures 2.1 and 2.2 show you the interface of the Math Game.

Figure 2.1: The program asks the user simple math questions.

Figure 2.2: When the user is finished, the program reports a score.

32

Соседние файлы в предмете Программирование на C++