Skip to content

Commit d5993d2

Browse files
Update chapter-02-simple-calculations.md
Review up to "Exercises: Simple calculations"
1 parent 1d84e9f commit d5993d2

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

chapter-02-simple-calculations.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Here are some examples of data types:
118118
- type **int number**: 1, 2, 3, 4, 5, …
119119
- type **double number**: 0.5, 3.14, -1.5, …
120120
- type **a letter from the alphabet** (symbol): 'a', 'b', 'c', …
121-
- type **text** (string): "Здрасти", "Hi", "Beer", …
121+
- type **text** (string): "Hello", "Hi", "Beer", …
122122
- type **day of the week**: Monday, Tuesday, …
123123

124124
## Reading floating-point numbers from the console
@@ -303,7 +303,7 @@ NaN
303303

304304
## Concatenating text and numbers
305305

306-
The operator **`+`** besides for summing up numbers, is also used for joining text (concatenation of two strings one after another). In programming, joining text with text or with number is called "concatenation". Here is how we can concatenate a text with a number with the operator **`+`**:
306+
The operator **`+`** besides for summing up numbers, is also used for joining text (concatenation of two strings one after another). In programming, joining text with other text or with number is called "concatenation". Here is how we can concatenate a text with a number with the operator **`+`**:
307307

308308
```Java
309309
String firstName = "Maria";
@@ -332,18 +332,18 @@ System.out.println(sum); // The sum is: 4
332332
```
333333

334334

335-
## Numerical Expressions
335+
## Numerical expressions
336336

337-
In programming we can calculate **numerical expressions**, for example:
337+
In programming, we can calculate **numerical expressions**, for example:
338338

339339
```Java
340340
int expr = (3 + 5) * (42);
341341
```
342-
The standard rule for priorities of arithmetic operations is applied: **multiplying and dividing are always done before adding and subtracting**. In case of an **expression in brackets it is calculated first**, but we already know all of that from school math.
342+
The standard rule for the precedence of arithmetic operations is applied: **multiplying and dividing are always done before adding and subtracting**. In the case of an **expression in brackets, it is calculated first**, but we already know all of that from math.
343343

344-
### Example: Calculating Trapezoid Area
344+
### Example: Calculating trapezoid area
345345

346-
Let’s write a program that inputs the lengths of the two bases of a trapezoid and its height (one floating-point number per line) and calculates the area of the trapezoid by the standard math formula.
346+
Write a program that reads as input from the console the lengths of the two bases of a trapezoid and its height (one floating-point number per line) and calculates the area of the trapezoid by the standard math formula.
347347

348348
```Java
349349
Scanner scanner = new Scanner(System.in);
@@ -355,22 +355,22 @@ double area = (b1 + b2) * h / 2.0;
355355
System.out.println("Trapezoid area = " + area);
356356
```
357357

358-
If we start the program and enter values for the sides: 3, 4 and 5, we will obtain the following result:
358+
If we start the program and enter values for sides: 3, 4, and 5, we will obtain the following result:
359359
```
360360
3
361361
4
362362
5
363363
Trapezoid area = 17.5
364364
```
365365

366-
#### Testing in the Judge System
366+
#### Testing in the Judge system
367367

368368
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#4](https://judge.softuni.bg/Contests/Practice/Index/649#4).
369369

370370

371-
### Example: Circle Area and Perimeter
371+
### Example: Circle area and perimeter
372372

373-
Let’s write a program which when enter a **radius r** of a circle **calculates the area and the perimeter** of the circle / round.
373+
Write a program that reads as input from the console a **radius r** of a circle, and **calculates its area and perimeter**.
374374

375375
Formulas:
376376
- Area = π \* r \* r
@@ -386,22 +386,22 @@ System.out.println("Area = " + Math.PI * r * r);
386386
// Math.PI - вградена в Java константа за π
387387
System.out.println("Perimeter = " + 2 * Math.PI * r);
388388
```
389-
НLet’s test the program with **radius `r = 10`**:
389+
Let’s test the program with **radius `r = 10`**:
390390

391391
![](/assets/chapter-2-1-images/04.Console-output-05.png)
392392

393-
#### Testing in the Judge System
393+
#### Testing in the Judge system
394394

395395
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#5](https://judge.softuni.bg/Contests/Practice/Index/649#5).
396396

397397

398-
### Example: 2D Rectangle Area
398+
### Example: 2D rectangle area
399399

400-
A rectangle is given with the **coordinates of two of its opposite angles**. Calculate its **area and perimeter**:
400+
A rectangle is given with the **coordinates of two of its opposite angles**. Write a program that calculates its **area and perimeter**:
401401

402402
<img alt="rectangleArea" src="/assets/chapter-2-1-images/05.Rectangle-area-01.png" width="250" height="200" />
403403

404-
In this tast we must take into account, that if from the bigger `x` we subtract the smaller `x`, we will obtain the length of the rectangle. Identically, if from the bigger `y` we subtract the smaller `y` we will obtain the height of the rectangle. What is left is to multiply both sides. Here is an example of an implementation of the described logic:
404+
In this tasк, we must take into account that we can obtain the length of the rectangle if we subtract the smaller `x` from the bigger `x`. Identically, if we subtract the smaller `y` from bigger `y`, we can obtain the rectangle height. Then we multiply both sides. Here is an example of an implementation of the described logic:
405405

406406
```Java
407407
Scanner scanner = new Scanner(System.in);
@@ -411,7 +411,7 @@ double y1 = Double.parseDouble(scanner.nextLine());
411411
double x2 = Double.parseDouble(scanner.nextLine());
412412
double y2 = Double.parseDouble(scanner.nextLine());
413413

414-
// Изчисляване страните на правоъгълника:
414+
// Calculate the sides of the rectangle:
415415
double width = Math.max(x1, x2) - Math.min(x1, x2);
416416
double height = Math.max(y1, y2) - Math.min(y1, y2);
417417

@@ -422,25 +422,25 @@ System.out.println(decimalFormat.format(2 * (width + height)));
422422

423423
We use **`Math.max(a, b)`** to find the bigger value from **`a`** and **`b`** and identically **`Math.min(a, b)`** to find the smaller of both values.
424424

425-
When the program is executed with the values from the coordinate system given in the condition we obtain the following result:
425+
When the program is executed with the values from the coordinate system above we obtain the following result:
426426

427427
![](/assets/chapter-2-1-images/04.Console-output-06.png)
428428

429-
#### Testing in the Judge System
429+
#### Testing in the Judge system
430430

431431
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/649#6](https://judge.softuni.bg/Contests/Practice/Index/649#6).
432432

433433

434-
## What we learned in this chapter?
434+
## What we have learned in this chapter?
435435

436-
To summarize what we learned from this chapter of the book:
437-
- **Reading text**: **`String str = scanner.nextLine();`** (as we have written in advance **`Scanner scanner = new Scanner(System.in);`**).
436+
To summarize what have we learned in this chapter of the book:
437+
- **Reading a text**: **`String str = scanner.nextLine();`** (as we have written in advance **`Scanner scanner = new Scanner(System.in);`**).
438438
- **Reading an integer**: **`int num = Integer.parseInt(scanner.nextLine());`**.
439439
- **Reading a floating-point number**: **`double num = Double.parseDouble(scanner.nextLine());`**.
440440
- **Calculations with numbers** and using the relevant **arithmetic operators** [`+`, `-`, `*`, `/`, `(`, `)`]: **`int sum = 5 + 3;`**.
441441
- **Printing a text by placeholders** on the console: **`System.out.printf("%d + %d = %d", 3, 5, 3 + 5);`**.
442442

443-
## Exercises: Simple Calculations
443+
## Exercises: Simple calculations
444444

445445
Let's solidify what we learned in this chapter with some exercises.
446446

0 commit comments

Comments
 (0)