Basics

You will find that while statements work well with applying business logic. The following is a simple example of using a while loop.

TYPE THIS:

RESULT:

Current

value

of

n

is

1

Current

value

of

n

is

2

Current

value

of

n

is

3

Current

value

of

n

is

4

Current

value

of

n

is

5

^ ControlLogic - Notepad

File Edit Format Help erase 1 erase 2: default:

strGoalStatement = "Drink 3 glasses of water a day."; break, strGoalStatement - "Send all my children to college "; break;

strGoalStatement - "(Goal Unknown)", break;

(belSetGoal) |

Console.WriteLinef'The goal of '" + strGoalStatement + '" was set.");

Console.WriteLine("No goal was set.");

O Create an if-then statement.

—• Use the Writeline method to send the appropriate value to the console.

, Save as the class name.

Note: See page 35 if you need more information on saving a file.

Console.WriteLinef'The goal of '" + strGoalStatement + '" was set.");

C:\WINNT\System32\cmd

Microsoft Uindoms 2000 [Uei <C> Copyright 1985-2000 Mil

C:\WINNT\System32\cmd

Microsoft Uindoms 2000 [Uei <C> Copyright 1985-2000 Mil n 5.00.2195] oft Corp.

C:\Documents and Settings\Adninistrator>cd C:\CSJiarp C:\Csharp>csc ControlLogic.cs

Microsoft <R> Uisual Clt Compiler Version 7.00.9148 [CLR version 615 ]

Copyright <C> Microsoft Corp 2000. fill rights reserved. C: NCsliarp>Contro lLogic . exe

The goal of 'Send all ny children to college.' was set.

■ The program displays the message about the goal set.

Was this article helpful?

0 0

Post a comment