Skip to content

Commit c45728a

Browse files
authored
Merge pull request #3585 from Youssef1313/patch-3
Follow coding conventions.
2 parents b933a4e + 477c473 commit c45728a

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

docs/get-started/csharp/tutorial-console.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -159,30 +159,30 @@ Let's continue by adding a more complex set of calculator code to your project.
159159
{
160160
static void Main(string[] args)
161161
{
162-
// Declare variables and then initialize to zero
162+
// Declare variables and then initialize to zero.
163163
int num1 = 0; int num2 = 0;
164164

165-
// Display title as the C# console calculator app
165+
// Display title as the C# console calculator app.
166166
Console.WriteLine("Console Calculator in C#\r");
167167
Console.WriteLine("------------------------\n");
168168

169-
// Ask the user to type the first number
169+
// Ask the user to type the first number.
170170
Console.WriteLine("Type a number, and then press Enter");
171171
num1 = Convert.ToInt32(Console.ReadLine());
172172

173-
// Ask the user to type the second number
173+
// Ask the user to type the second number.
174174
Console.WriteLine("Type another number, and then press Enter");
175175
num2 = Convert.ToInt32(Console.ReadLine());
176176

177-
// Ask the user to choose an option
177+
// Ask the user to choose an option.
178178
Console.WriteLine("Choose an option from the following list:");
179179
Console.WriteLine("\ta - Add");
180180
Console.WriteLine("\ts - Subtract");
181181
Console.WriteLine("\tm - Multiply");
182182
Console.WriteLine("\td - Divide");
183183
Console.Write("Your option? ");
184184

185-
// Use a switch statement to do the math
185+
// Use a switch statement to do the math.
186186
switch (Console.ReadLine())
187187
{
188188
case "a":
@@ -198,7 +198,7 @@ Let's continue by adding a more complex set of calculator code to your project.
198198
Console.WriteLine($"Your result: {num1} / {num2} = " + (num1 / num2));
199199
break;
200200
}
201-
// Wait for the user to respond before closing
201+
// Wait for the user to respond before closing.
202202
Console.Write("Press any key to close the Calculator console app...");
203203
Console.ReadKey();
204204
}
@@ -282,7 +282,7 @@ Let's change the code to handle this error.
282282
1. Replace it with the following code:
283283

284284
```csharp
285-
// Ask the user to enter a non-zero divisor until they do so
285+
// Ask the user to enter a non-zero divisor until they do so.
286286
while (num2 == 0)
287287
{
288288
Console.WriteLine("Enter a non-zero divisor: ");
@@ -311,9 +311,9 @@ To fix this error, we must refactor the code that we've previously entered.
311311

312312
#### Revise the code
313313

314-
Rather than rely on the `program` class to handle all the code, we'll divide our app into two classes: `calculator` and `program`.
314+
Rather than rely on the `program` class to handle all the code, we'll divide our app into two classes: `Calculator` and `Program`.
315315

316-
The `calculator` class will handle the bulk of the calculation work, and the `program` class will handle the user interface and error-capturing work.
316+
The `Calculator` class will handle the bulk of the calculation work, and the `Program` class will handle the user interface and error-capturing work.
317317

318318
Let's get started.
319319

@@ -328,16 +328,16 @@ Let's get started.
328328

329329
```
330330

331-
1. Next, add a new `calculator` class, as follows:
331+
1. Next, add a new `Calculator` class, as follows:
332332

333333
```csharp
334334
class Calculator
335335
{
336336
public static double DoOperation(double num1, double num2, string op)
337337
{
338-
double result = double.NaN; // Default value is "not-a-number" which we use if an operation, such as division, could result in an error
338+
double result = double.NaN; // Default value is "not-a-number" which we use if an operation, such as division, could result in an error.
339339
340-
// Use a switch statement to do the math
340+
// Use a switch statement to do the math.
341341
switch (op)
342342
{
343343
case "a":
@@ -350,13 +350,13 @@ Let's get started.
350350
result = num1 * num2;
351351
break;
352352
case "d":
353-
// Ask the user to enter a non-zero divisor
353+
// Ask the user to enter a non-zero divisor.
354354
if (num2 != 0)
355355
{
356356
result = num1 / num2;
357357
}
358358
break;
359-
// Return text for an incorrect option entry
359+
// Return text for an incorrect option entry.
360360
default:
361361
break;
362362
}
@@ -366,26 +366,26 @@ Let's get started.
366366

367367
```
368368

369-
1. Then, add a new `program` class, as follows:
369+
1. Then, add a new `Program` class, as follows:
370370

371371
```csharp
372372
class Program
373373
{
374374
static void Main(string[] args)
375375
{
376376
bool endApp = false;
377-
// Display title as the C# console calculator app
377+
// Display title as the C# console calculator app.
378378
Console.WriteLine("Console Calculator in C#\r");
379379
Console.WriteLine("------------------------\n");
380380

381381
while (!endApp)
382382
{
383-
// Declare variables and set to empty
383+
// Declare variables and set to empty.
384384
string numInput1 = "";
385385
string numInput2 = "";
386386
double result = 0;
387387

388-
// Ask the user to type the first number
388+
// Ask the user to type the first number.
389389
Console.Write("Type a number, and then press Enter: ");
390390
numInput1 = Console.ReadLine();
391391

@@ -396,7 +396,7 @@ Let's get started.
396396
numInput1 = Console.ReadLine();
397397
}
398398

399-
// Ask the user to type the second number
399+
// Ask the user to type the second number.
400400
Console.Write("Type another number, and then press Enter: ");
401401
numInput2 = Console.ReadLine();
402402

@@ -407,7 +407,7 @@ Let's get started.
407407
numInput2 = Console.ReadLine();
408408
}
409409

410-
// Ask the user to choose an operator
410+
// Ask the user to choose an operator.
411411
Console.WriteLine("Choose an operator from the following list:");
412412
Console.WriteLine("\ta - Add");
413413
Console.WriteLine("\ts - Subtract");
@@ -433,11 +433,11 @@ Let's get started.
433433

434434
Console.WriteLine("------------------------\n");
435435

436-
// Wait for the user to respond before closing
436+
// Wait for the user to respond before closing.
437437
Console.Write("Press 'n' and Enter to close the app, or press any other key and Enter to continue: ");
438438
if (Console.ReadLine() == "n") endApp = true;
439439

440-
Console.WriteLine("\n"); // Friendly linespacing
440+
Console.WriteLine("\n"); // Friendly linespacing.
441441
}
442442
return;
443443
}
@@ -480,9 +480,9 @@ namespace Calculator
480480
{
481481
public static double DoOperation(double num1, double num2, string op)
482482
{
483-
double result = double.NaN; // Default value is "not-a-number" which we use if an operation, such as division, could result in an error
483+
double result = double.NaN; // Default value is "not-a-number" which we use if an operation, such as division, could result in an error.
484484
485-
// Use a switch statement to do the math
485+
// Use a switch statement to do the math.
486486
switch (op)
487487
{
488488
case "a":
@@ -495,13 +495,13 @@ namespace Calculator
495495
result = num1 * num2;
496496
break;
497497
case "d":
498-
// Ask the user to enter a non-zero divisor
498+
// Ask the user to enter a non-zero divisor.
499499
if (num2 != 0)
500500
{
501501
result = num1 / num2;
502502
}
503503
break;
504-
// Return text for an incorrect option entry
504+
// Return text for an incorrect option entry.
505505
default:
506506
break;
507507
}
@@ -514,18 +514,18 @@ namespace Calculator
514514
static void Main(string[] args)
515515
{
516516
bool endApp = false;
517-
// Display title as the C# console calculator app
517+
// Display title as the C# console calculator app.
518518
Console.WriteLine("Console Calculator in C#\r");
519519
Console.WriteLine("------------------------\n");
520520

521521
while (!endApp)
522522
{
523-
// Declare variables and set to empty
523+
// Declare variables and set to empty.
524524
string numInput1 = "";
525525
string numInput2 = "";
526526
double result = 0;
527527

528-
// Ask the user to type the first number
528+
// Ask the user to type the first number.
529529
Console.Write("Type a number, and then press Enter: ");
530530
numInput1 = Console.ReadLine();
531531

@@ -536,7 +536,7 @@ namespace Calculator
536536
numInput1 = Console.ReadLine();
537537
}
538538

539-
// Ask the user to type the second number
539+
// Ask the user to type the second number.
540540
Console.Write("Type another number, and then press Enter: ");
541541
numInput2 = Console.ReadLine();
542542

@@ -547,7 +547,7 @@ namespace Calculator
547547
numInput2 = Console.ReadLine();
548548
}
549549

550-
// Ask the user to choose an operator
550+
// Ask the user to choose an operator.
551551
Console.WriteLine("Choose an operator from the following list:");
552552
Console.WriteLine("\ta - Add");
553553
Console.WriteLine("\ts - Subtract");
@@ -573,11 +573,11 @@ namespace Calculator
573573

574574
Console.WriteLine("------------------------\n");
575575

576-
// Wait for the user to respond before closing
576+
// Wait for the user to respond before closing.
577577
Console.Write("Press 'n' and Enter to close the app, or press any other key and Enter to continue: ");
578578
if (Console.ReadLine() == "n") endApp = true;
579579

580-
Console.WriteLine("\n"); // Friendly linespacing
580+
Console.WriteLine("\n"); // Friendly linespacing.
581581
}
582582
return;
583583
}

0 commit comments

Comments
 (0)