Skip to content

Commit

Permalink
Bug fixes:
Browse files Browse the repository at this point in the history
 - in the console -> on the console
 - at the console -> on the console
  • Loading branch information
nakov committed Feb 4, 2019
1 parent 9c0b493 commit 812681a
Show file tree
Hide file tree
Showing 21 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The **Web application** is expected to look similarly to the following:

![](/assets/chapter-1-images/08.Numbers-sum-web-01.png)

As a difference compared to console applications, which read and write the data in the form of a text in the console, web applications have **a web-based user interface**. Web applications **are being loaded from some Internet address** (URL) through a standard web browser. Users write input data in a page, visualized from the web browser, the data is processed on a web server and the results are shown again in a page of the web browser. For our web application we are going to use **the ASP.NET MVC technology**, which allows creating of **web applications with the programming language C\#** in the development environment **Visual Studio**.
As a difference compared to console applications, which read and write the data in the form of a text on the console, Web applications have **a Web-based user interface**. Web applications **are being loaded from some Internet address** (URL) through a standard web browser. Users write input data in a page, visualized from the web browser, the data is processed on a web server and the results are shown again in a page of the web browser. For our web application we are going to use **the ASP.NET MVC technology**, which allows creating of **web applications with the programming language C\#** in the development environment **Visual Studio**.

## Creating a New ASP.NET MVC Project

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Some programming languages do not use a compiler and are being **interpreted dir

**An environment for development** \(Integrated Development Environment – **IDE**\) is an union of traditional tools for development of software applications. In the development environment we write code, compile and execute the programs. Development environments integrate in them **a text editor** for writing code, **a programming language**, **a compiler or an interpreter** and **a runtime environment** for executing programs, **a debugger** for tracking the program and seeking out errors, **tools for user interface design** and other tools and add-ons.

**Environments for development** are convenient, because they integrate everything necessary for the development of the program, without the need to exit the environment. If we don't use an environment for development, we will have to write the code in a text editor, to compile it with a command in the console, to run it with another command in the console and to write more additional commands when needed, which is very time consuming. That is why most of the programmers use an IDE in their everyday work.
**Environments for development** are convenient, because they integrate everything necessary for the development of the program, without the need to exit the environment. If we don't use an environment for development, we will have to write the code in a text editor, to compile it with a command on the console, to run it with another command on the console and to write more additional commands when needed, which is very time consuming. That is why most of the programmers use an IDE in their everyday work.

For programming with **the C\# language** the most commonly used IDE is **Visual Studio**, which is developed and distributed freely by Microsoft and can be downloaded from: [https://www.visualstudio.com/downloads/](https://www.visualstudio.com/downloads/). Alternatives of Visual Studio are **Rider** \([https://www.jetbrains.com/rider/](https://www.jetbrains.com/rider/)\) and **MonoDevelop** / **Xamarin Studio** \([http://www.monodevelop.com](http://www.monodevelop.com)\) and **SharpDevelop** \([http://www.icsharpcode.net/OpenSource/SD/](http://www.icsharpcode.net/OpenSource/SD/)\). In the current book, we are going to use the development environment Visual Studio.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Here is how our program should look like in Visual Studio:

![](/assets/chapter-1-images/01.Hello-csharp-04.png)

The command `Console.WriteLine("Hello C#")` in the C\# language means to execute printing (`WriteLine(…)`) in the console (`Console`) and to print the text message `Hello C#`, which we have to surround by quotation marks, in order to clarify that this is a text. In the end of each command in the C\# language the symbol `;` is being put and it says that the command ends in that place (it doesn't continue on the next line).
The command `Console.WriteLine("Hello C#")` in the C\# language means to execute printing (`WriteLine(…)`) on the console (`Console`) and to print the text message `Hello C#`, which we have to surround by quotation marks, in order to clarify that this is a text. In the end of each command in the C\# language the symbol `;` is being put and it says that the command ends in that place (it doesn't continue on the next line).

This command is very typical in programming: we say a given **object** should be found \(in this case the console\) and some **action** should be executed upon it \(in this case it is printing something that is given inside the brackets\). More technically explained, we call the method `WriteLine(…)` from the class `Console` and give as a parameter to it a text literal `"Hello C#"`.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Problem: Integer to Base

Write a method **`IntegerToBase(number, toBase)`**, which takes as parameters an integer and a base of a numeral system and returns the integer converted to the given numeral system. After this the result should be printed in the console. The input number will always be in decimal numeral system, and the base parameter will be between 2 and 10.
Write a method **`IntegerToBase(number, toBase)`**, which takes as parameters an integer and a base of a numeral system and returns the integer converted to the given numeral system. After this the result should be printed on the console. The input number will always be in decimal numeral system, and the base parameter will be between 2 and 10.

## Sample Input and Output

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Write a program, which takes an integer **`n`** and on the next lines prints **`
- When **`messageType`** is **`warning`** read only **`message`**.
- When **`messageType`** is **`error`** read **`operation`** + **`message`** + **`errorCode`** (each on a new line).

Print in the console **each read message**, formatted depending on its **`messageType`**. After the headline of the message print as much **`=`**, **as the length** of the said **headline** and print **an empty line** after each message (to understand in detail look at the examples).
Print on the console **each read message**, formatted depending on its **`messageType`**. After the headline of the message print as much **`=`**, **as the length** of the said **headline** and print **an empty line** after each message (to understand in detail look at the examples).

The problem should be solved by defining four methods: **`ShowSuccessMessage()`**, **`ShowWarningMessage()`**, **`ShowErrorMessage()`** and **`ReadAndProcessMessage()`**, so that only the last method is invoked by the **`Main()`** method:

Expand Down
2 changes: 1 addition & 1 deletion Content/Chapter-10-methods/exercises-methods/nth-digit.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Problem: N-th Digit

Create a method **`FindNthDigit(number, index)`**, which takes a number and index N as parameters and prints the N-th digit of the number (counting from right to left and starting from 1). After that print the result in the console.
Create a method **`FindNthDigit(number, index)`**, which takes a number and index N as parameters and prints the N-th digit of the number (counting from right to left and starting from 1). After that print the result on the console.

## Sample Input and Output

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Let's summarize what we learned in this chapter of the book:

## The Exercises

We have a lot of practical work. Solve these exercises to learn how to work with variables and data types, reading and writing at the console, using data and calculations:
We have a lot of practical work. Solve these exercises to learn how to work with variables and data types, reading and writing on the console, using data and calculations:

* [Blank Visual Studio Solution](/Content/Chapter-2-1-simple-calculations/exercises-simple-calculations/blank-visual-studio-solution.md)
* [Problem: Calculating Square Area](/Content/Chapter-2-1-simple-calculations/exercises-simple-calculations/square-area/square-area.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Printing Text and Numbers

In C\#, when printing a text, numbers and other data in the console, **we can join them** by using templates `{0}`, `{1}`, `{2}` etc. In programming, these templates are called **placeholders**.
In C\#, when printing a text, numbers and other data on the console, **we can join them** by using templates `{0}`, `{1}`, `{2}` etc. In programming, these templates are called **placeholders**.

```csharp
var firstName = Console.ReadLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In order to read an **integer** \(not a float\) **number** from the console, we
var num = int.Parse(Console.ReadLine());
```

The above line of C\# code **reads an integer** from the first line at the console.
The above line of C\# code **reads an integer** from the first line on the console.

## Example: Calculating a Square Area Using Side A

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Generally the **system console** represents a text terminal, which means that it

In most operating systems, the **console** is available as a standalone application on which we write console commands. It is called a **Command Prompt** in Windows, and a **Terminal** in Linux and Mac. The console runs console applications. They read text from the command line and print text on the console. In this book we are going to learn programming mostly through creating **console applications**.

In the next examples we shall **read data** \(like integers, floating-point numbers and strings\) from the console and will **print data** at the console \(text and numbers\).
In the next examples we shall **read data** \(like integers, floating-point numbers and strings\) from the console and will **print data** on the console \(text and numbers\).

Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ This method **rounds the decimal** number up to a **specified number of characte

### Printing the Result

Finally, what remains is to print the calculated results in the console.
Finally, what remains is to print the calculated results on the console.

## Testing in the Judge System

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ For the output, in order to spare one **`else` condition** in the construction,

### Printing the Result

Finally, we need to display the calculated result in the console.
Finally, we need to display the calculated result on the console.

## Testing in the Judge System

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ We also need to do one more check – whether the time of student's arrival is *

## Printing the Result

Finally, what remains is to print the result in the console. According to the requirements, if the student arrived right on time (**not even a minute difference**), we do not need to print a second result. This is why we apply the following **condition**:
Finally, what remains is to print the result on the console. According to the requirements, if the student arrived right on time (**not even a minute difference**), we do not need to print a second result. This is why we apply the following **condition**:

![](/assets/chapter-4-2-images/01.On-time-for-the-exam-08.png)

Actually, for the purposes of the task, printing the result **in the console** can be done on a much earlier stage – during the calculations. This, however, is not a very good practice. **Why?**
Actually, for the purposes of the task, printing the result **on the console** can be done on a much earlier stage – during the calculations. This, however, is not a very good practice. **Why?**

Let's examine the idea that our code is not 10 lines, but 100 or 1000! One day, printing the result will not be done in the console, but will be written in a **file** or displayed as a **web application**. Then, how many places in the code you will make changes at, due to such a correction? Are you sure you won't miss some places?
Let's examine the idea that our code is not 10 lines, but 100 or 1000! One day, printing the result will not be done on the console, but will be written in a **file** or displayed as a **web application**. Then, how many places in the code you will make changes at, due to such a correction? Are you sure you won't miss some places?

<table><tr><td><img src="/assets/alert-icon.png" style="max-width:50px" /></td>
<td>Always consider the code that contains logical calculations as a separate part, different from the part that processes the input and output data. It has to be able to work regardless of how the data is passed to it and where the result will be displayed.</td></tr></table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ For short and clear conditions, such as the above example for even and odd numbe

### Printing the Output

Finally, what remains is to print the calculated result in the console:
Finally, what remains is to print the calculated result on the console:

![](/assets/chapter-4-2-images/03.Operations-08.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The input data will be read from the console and will consist of **two lines**:

## Output Data

**Two lines** must be printed in the console.
**Two lines** must be printed on the console.

* On the **first** line – "**Somewhere in {destination}**" among "**Bulgaria**", "**Balkans**" and "**Europe**".
* On the **second** line – "{**Vacation type**} – {**Amount spent**}".
Expand Down Expand Up @@ -90,7 +90,7 @@ After that, we need to apply a condition to check the value of the **season**. B

### Printing the Result

What remains is to display the calculated result in the console:
What remains is to display the calculated result on the console:

![](/assets/chapter-4-2-images/02.Trip-07.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Write a program that enters **n integers** (**n** > 0) and finds **the max numbe

## Hints and Guidelines

We will first enter one number **`n`** (the number of integers that are about to be entered). We assign the current maximum **`max`** an initial neutral value, for example **-10000000000000** (or **`int.MinValue`**). Using a **`for` loop** that is iterated **n-1 times**, we read one integer **`num`** on each iteration. If the read number **`num`** is higher than the current maximum **`max`**, we assign the value of the **`num`** to the **`max`** variable. Finally, in **`max`** we must have stored the highest number. We print the number in the console.
We will first enter one number **`n`** (the number of integers that are about to be entered). We assign the current maximum **`max`** an initial neutral value, for example **-10000000000000** (or **`int.MinValue`**). Using a **`for` loop** that is iterated **n-1 times**, we read one integer **`num`** on each iteration. If the read number **`num`** is higher than the current maximum **`max`**, we assign the value of the **`num`** to the **`max`** variable. Finally, in **`max`** we must have stored the highest number. We print the number on the console.

![](/assets/chapter-5-images/05.Max-number-01.png)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lab: Turtle Graphics GUI Application

In the current chapter we learned about **loops** as a programming construction that allows to repeat a particular action or a group of actions multiple times. Now let's play with them. In order to do that, we will draw some figures that will consist of a large number of repeating graphical elements, but this time we will not do it in the console, but in a graphical environment using "**turtle graphics**". It will be interesting. And it is not hard at all. Try it!
In the current chapter we learned about **loops** as a programming construction that allows to repeat a particular action or a group of actions multiple times. Now let's play with them. In order to do that, we will draw some figures that will consist of a large number of repeating graphical elements, but this time we will not do it on the console, but in a graphical environment using "**turtle graphics**". It will be interesting. And it is not hard at all. Try it!

## What Shall We Build?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ After we have calculated the length of the roof we make a loop from 0 to **`roof

![](/assets/chapter-6-images/09.House-05.png)

* We print in the console: "**dashes**" (**`padding / 2`** times) + "**stars**" (**`stars`** times) + "**dashes**" (**`padding / 2`** times).
* We print on the console: "**dashes**" (**`padding / 2`** times) + "**stars**" (**`stars`** times) + "**dashes**" (**`padding / 2`** times).

![](/assets/chapter-6-images/09.House-06.png)

Expand All @@ -91,7 +91,7 @@ After we have calculated the length of the roof we make a loop from 0 to **`roof

After we have finished with the **roof**, it is time for **the base**. It is easier to print:
* We start with a loop from 0 to n (not inclusive).
* We print in the console: `|` + `*` (**`n - 2`** times) + `|`.
* We print on the console: `|` + `*` (**`n - 2`** times) + `|`.

![](/assets/chapter-6-images/09.House-08.png)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Example: Rectangle Made of 10 x 10 Stars

Print in the console a rectangle made out of **10 x 10** stars.
Print on the console a rectangle made out of **10 x 10** stars.

|Input|Output|
|---|---|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Example: Rectangle Made of N x N Stars

Write a program that gets a positive integer **n** and prints in the console **a rectangle made out of N x N stars**.
Write a program that gets a positive integer **n** and prints on the console **a rectangle made out of N x N stars**.

|Input|Output|Input|Output|Input|Output|
|---|---|---|---|---|---|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Construction workers have to transfer a total of **x bricks**. **Workers** are *

### Input

At the console **3 integers** are given, one per line:
On the console **3 integers** are given, one per line:
* **The number of bricks x** is read from the first line.
* **The number of workers w** is read from the second line
* **The capacity of the trolley m** is read from the third line.
Expand Down

0 comments on commit 812681a

Please sign in to comment.