Skip to content

Commit 8f20b22

Browse files
committed
Chapter 3.1 - Grammarly + Upper Letter Titles
1 parent 234b0db commit 8f20b22

File tree

1 file changed

+17
-183
lines changed

1 file changed

+17
-183
lines changed

chapter-03-simple-conditions.md

Lines changed: 17 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ if (Boolean condition) {
6868
}
6969
```
7070

71-
### Problem: Excellent Grade
71+
### Problem: Excellent Result
7272

7373
We take the grade as an input argument to our function and upon evaluation, we check if the input value is an excellent grade (**`≥ 5.50`**).
7474

7575
![](assets/chapter-3-1-images/01.ЕxcellentResult-01.png)
7676

77-
Test the example code locally. Try entering different grades, for example, **4.75**, **5.49**, **5.50** and **6.00**. For grades **less than 5.50** the program will not give any output, however for grades of **5.50 or greater**, the output will be "**Excellent!**". The function is called by simply writing its name and filling the input value in the parenthesis:
77+
Test the example code locally. Try entering different grades, for example, **4.75**, **5.49**, **5.50**, and **6.00**. For grades **less than 5.50** the program will not give any output, however for grades of **5.50 or greater**, the output will be "**Excellent!**". The function is called by simply writing its name and filling the input value in the parenthesis:
7878

7979
![](assets/chapter-3-1-images/01.ЕxcellentResult-02.png)
8080

@@ -97,7 +97,7 @@ if (Boolean condition) {
9797

9898
```
9999

100-
### Problem: Excellent Grade or Not
100+
### Problem: Excellent or Not
101101

102102
Similarly to the example above, we input a grade and check if it is excellent, but this time we should **output a result in both cases**:
103103

@@ -113,7 +113,7 @@ You can test your solution at the following link: [https://judge.softuni.org/Con
113113
When we have **only one command** in the body of the **`if` statement**, we can **skip the curly braces**, indicating the body of the conditional operator. When we need to execute a **block of code** (group of commands), curly braces are **mandatory**. In case the braces are omitted, **only the first line of code** will be executed after the **`if` statement**.
114114

115115
<table><tr><td><img src="/assets/alert-icon.png" style="max-width:50px" /></td>
116-
<td>It is a good practice to <strong> always include curly braces</strong> since this makes the code more readable, neater and cleaner.</td>
116+
<td>It is a good practice to <strong> always include curly braces</strong> since this makes the code more readable, neater, and cleaner.</td>
117117
</tr></table>
118118

119119
Here is an example, where omitting the curly braces leads to confusion:
@@ -145,7 +145,7 @@ The problem can be solved with a single **`if-else`** structure and the operator
145145
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/929#2](https://judge.softuni.org/Contests/Practice/Index/929#2).
146146

147147

148-
### Problem: Finding The Greater Number
148+
### Problem: Greater Number
149149

150150
Write a program that reads two integers and outputs the greater one.
151151

@@ -190,7 +190,7 @@ else {
190190
}
191191
```
192192

193-
### Problem: Numbers One Through 9 in English
193+
### Problem: Number 0...9 to Text
194194

195195
Print the digits one through nine in English on the console (the numbers are passed as arguments of the function upon call). We can take the digit and through a **series of conditions** print the corresponding English word on the console:
196196

@@ -260,7 +260,7 @@ Please note that for this problem the Judge system is set up to ignore any non-n
260260
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/929#5](https://judge.softuni.org/Contests/Practice/Index/929#5).
261261

262262

263-
### Problem: Summing Up Seconds
263+
### Problem: Sum Seconds
264264

265265
Three athletes finish with some **number of seconds** (between **1** and **50**). Write a function that takes the times of the contestants and calculates their **combined time** in **minutes:seconds** format. Seconds are to be printed with a **leading zero** (2 -> "02", 7 -> "07", 35 -> "35").
266266

@@ -341,173 +341,7 @@ To date, we have written quite a lot of code and oftentimes there were mistakes,
341341

342342
We add a point, at which our function will stop its execution - a **breakpoint** after which we start the program in **debug mode** through pressing [**F5**]. The program will follow its course until it reaches our interrupt (**breakpoint**). After which we the execution can proceed to the **next line of code** by pressing [**F10**].
343343

344-
## Exercises: Simple Conditions
345-
346-
Now let's practice the lessons learned in this chapter with a few practical exercises.
347-
348-
### Empty Visual Studio Code file
349-
350-
We start Visual Studio Code and create a new file [**File**] -> [**New File**]:
351-
352-
![](assets/chapter-3-1-images/00.Visual-studio-01.png)
353-
354-
After that, we will see a new file, which is anonymous for the moment to our system. To be recognized correctly, we need to save our code as a **JavaScript** file: [**File**] -> [**Save**]:
355-
356-
![](assets/chapter-3-1-images/00.VisualStuido-02.png)
357-
358-
After this a pop-up window will open, where we need to specify a name for our file and give it the **obligatory .js file extension**:
359-
360-
![](assets/chapter-3-1-images/00.VisualStuido-03.png)
361-
362-
363-
### Problem: Excellent Grade
364-
365-
The first exercise for this topic is to write a **JavaScript function**, which **takes a grade** (decimal number) and prints "**Excellent!**", if the grade is **5.50** or higher.
366-
367-
#### Sample Input and Output
368-
369-
| Input | Output |
370-
| --- | ---- |
371-
| 6 | Excellent! |
372-
| 5 | (no output) |
373-
| 5.5 | Excellent! |
374-
| 5.49 | (no output) |
375-
376-
#### Hints and Pointers
377-
378-
We create a **new anonymous file** by clicking [**File**] -> [**New File**]. Then we save it ([**File**] -> [**Save**]), as a **JavaScript file**, with the file extension **.js**
379-
380-
Now that we have prepared a JavaScript file, we have to solve the problem. To this effect we write the following code:
381-
382-
![](assets/chapter-3-1-images/01.ЕxcellentResult-01.png)
383-
384-
**Start** the program with [**Ctrl+F5**], so we can **test** it with different input values:
385-
386-
![](assets/chapter-3-1-images/01.ЕxcellentResult-03.png)
387-
388-
For values **greater than 5.50** - there is an **Excellent!** output.
389-
390-
![](assets/chapter-3-1-images/01.ЕxcellentResult-04.png)
391-
392-
For values **less than 5.50** - there is no output.
393-
394-
#### Testing in The Judge System
395-
396-
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/929#0](https://judge.softuni.org/Contests/Practice/Index/929#0).
397-
398-
![](assets/chapter-3-1-images/01.ЕxcellentResult-05.png)
399-
400-
![](assets/chapter-3-1-images/01.ЕxcellentResult-06.png)
401-
402-
403-
### Problem: Excellent Grade or Not
404-
405-
The next exercise for this topic is to write a **JavaScript function**, which **takes a grade** (decimal number) and prints "**Excellent!**", if the grade is **5.50** or higher, or “**Not excellent.**” if it is not.
406-
407-
#### Sample Input and Output
408-
409-
| Input | Output |
410-
| --- | ---- |
411-
| 6 | Excellent! |
412-
| 5 | Not excellent. |
413-
| 5.5 | Excellent! |
414-
| 5.49 | Not excellent. |
415-
416-
#### Hints and Pointers
417-
418-
Firstly we create a **new JavaScript file**. After that, we **write the code** of the program. You may use the following example code as a hint:
419-
420-
![](assets/chapter-3-1-images/02.Excellent-or-not-01.png)
421-
422-
After that, we call the function and pass some sample data, so we can test its functionality:
423-
424-
![](assets/chapter-3-1-images/02.Excellent-or-not-02.png)
425-
426-
![](assets/chapter-3-1-images/02.Excellent-or-not-03.png)
427-
428-
#### Testing in The Judge System
429-
430-
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/929#1](https://judge.softuni.org/Contests/Practice/Index/929#1).
431-
432-
![](assets/chapter-3-1-images/02.Excellent-or-not-04.png)
433-
434-
435-
### Problem: Even or Odd
436-
437-
Write a function that checks whether an **integer** input is either **even** or **odd** and prints the result on the console.
438-
439-
#### Sample Input and Output
440-
441-
| Input | Output |
442-
| --- | ---- |
443-
| 2 | even |
444-
| 3 | odd |
445-
| 25 | odd |
446-
| 1024 | even |
447-
448-
#### Hints and Pointers
449-
450-
Again firstly we must create a **new JavaScript file**. Then the check if a number is either even or odd can be made with the operator **`%`**, which will return the **remainder from an integer divided by 2** as follows: **`let isEven = (num % 2 == 0)`**.
451-
452-
Now we have to **start** the program with [**Ctrl+F5**] and test it:
453-
454-
![](assets/chapter-3-1-images/03.Even-or-odd-02.png)
455-
456-
#### Testing in The Judge System
457-
458-
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/929#2](https://judge.softuni.org/Contests/Practice/Index/929#2).
459-
460-
461-
### Problem: Find The Greater Number
462-
463-
Write a function that takes **two integers** and prints the bigger one on the console.
464-
465-
#### Sample Input and Output
466-
467-
| Input | Output |
468-
|-----|------|
469-
|5<br>3| 5 |
470-
|3<br>5| 5 |
471-
|10<br>10| 10 |
472-
|-5<br>5| 5 |
473-
474-
#### Hints and pointers
475-
476-
As usual, first, we need to create a **new JavaScript file**. For the main logic, we need a single **`if-else`** construct. The code below is deliberately blurred, however, there is enough visible to give you some hint, so you can complete it yourself:
477-
![](assets/chapter-3-1-images/04.Greater-number-01.png)
478-
479-
When we are done with the implementation of the solution, we call the function and pass it example parameters, we **run** the program with [**Ctrl+F5**] and test it:
480-
481-
![](assets/chapter-3-1-images/04.Greater-number-02.png)
482-
483-
#### Testing in The Judge System
484-
485-
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/929#3](https://judge.softuni.org/Contests/Practice/Index/929#3).
486-
487-
488-
### Problem: Output a Digit's Word Equivalent
489-
490-
Write a function that takes an **integer in the range** [**0 … 9**] and prints **its word equivalent** in English. If the number is outside the given range, the function should return “**number too big**”.
491-
492-
#### Sample Input and Output
493-
494-
| Input | Output |
495-
| --- | ---- |
496-
| 5 | five |
497-
| 1 | one |
498-
| 9 | nine |
499-
| 10 | number too big |
500-
501-
#### Hints and Pointers
502-
503-
We can use a sequence of **`if-else`** statements to cover every one of the possible **11 cases**.
504-
505-
#### Testing in The Judge System
506-
507-
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/929#4](https://judge.softuni.org/Contests/Practice/Index/929#4).
508-
509-
510-
### Problem: Guess the Password
344+
### Problem: Password Guess
511345

512346
Write a function that **accepts a password** (one line of random text) and checks if the input **matches** the phrase “**s3cr3t!P@ssw0rd**”. If it matches, print “**Welcome**”, otherwise print “**Wrong password!**”.
513347

@@ -528,9 +362,9 @@ Use an **`if-else`** statement.
528362
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/929#8](https://judge.softuni.org/Contests/Practice/Index/929#8).
529363

530364

531-
### Problem: Numbers from 100 to 200
365+
### Problem: Number 100...200
532366

533-
Write a function that **accepts an integer** as a parameter and checks if it is **below 100**, **between 100 and 200** or **over 200**. Print the appropriate messages as per the examples below.
367+
Write a function that **accepts an integer** as a parameter and checks if it is **below 100**, **between 100 and 200**, or **over 200**. Print the appropriate messages as per the examples below.
534368

535369
#### Sample Input and Output
536370

@@ -545,7 +379,7 @@ Write a function that **accepts an integer** as a parameter and checks if it is
545379
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/929#9](https://judge.softuni.org/Contests/Practice/Index/929#9).
546380

547381

548-
### Problem: Identical Words
382+
### Problem: Equal Words
549383

550384

551385
Write a function that **accepts two words** as parameters and checks if they are the same. A comparison should be case-insensitive and the output should be either “**yes**” or “**no**”.
@@ -569,7 +403,7 @@ Before the comparison, both words should be in lower case, so that case (upperca
569403
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/929#10](https://judge.softuni.org/Contests/Practice/Index/929#10).
570404

571405

572-
### Problem: Speed Assessment
406+
### Problem: Speed Info
573407

574408
Write a function, that **takes speed** (decimal number) as a parameter and prints **speed information**. For speeds **up to 10** (inclusive), print "**slow**". For speed **over 10** and **up to 50**, print "**average**". For speeds **over 50** and **up to 150**, print "**fast**". For speeds **over 150** and **up to 1000**, print "**ultra fast**". For higher speed, print "**extremely fast**".
575409

@@ -596,7 +430,7 @@ The first argument of the function is the type of shape (**`square`**, **`rectan
596430
* If the shape is a **square**, the next argument will be one number - the length of its side.
597431
* If the shape is a **rectangle**, the next argument will be two numbers - the lengths of its sides.
598432
* If the shape is a **circle**, the next argument will be one number - the radius of the circle.
599-
* If the shape is a **triangle**, the next argument will be two numbers - its base and the corresponding altitude.
433+
* If the shape is a **triangle**, the next argument will be two numbers - base and the corresponding altitude.
600434

601435
The result should be rounded up to the **third decimal point**.
602436

@@ -637,7 +471,7 @@ Add 15 minutes and check using a set of conditions. If minutes are over 59 **inc
637471
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/929#13](https://judge.softuni.org/Contests/Practice/Index/929#13).
638472

639473

640-
### Problem: Tree Equal Numbers
474+
### Problem: 3 Equal Numbers
641475

642476
Write a function that takes **3 numbers** as arguments and prints whether they are the same (**yes** / **no**).
643477

@@ -654,7 +488,7 @@ Write a function that takes **3 numbers** as arguments and prints whether they a
654488
Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/929#14](https://judge.softuni.org/Contests/Practice/Index/929#14).
655489

656490

657-
### Problem: \*Convert a Number to Words
491+
### Problem: Number 0...100 to Text
658492

659493
Write a function that converts numbers in the range of [**0 … 100**] in text.
660494

@@ -679,13 +513,13 @@ Test your solution here: [https://judge.softuni.org/Contests/Practice/Index/929#
679513

680514
Now since we have completed a few exercises on **conditional statements (checks)**, let's do something a bit more interesting: an application with a Graphical User Interface (GUI) for currency conversion. We will employ the knowledge from this chapter to select from the different available currencies and make calculations as per the appropriate exchange rates for the given currency.
681515

682-
### Problem: \*\*Currency Converter
516+
### Problem: \*\* Currency Converter
683517

684518
Now let's see how to create a graphical (**GUI**) application for **currency conversion**. The application will look similar to the picture below:
685519

686520
![](assets/chapter-3-1-images/14.Converter-01.png)
687521

688-
For visualization, we will use an **internet browser**, that interprets **HTML** pages. We will create a new page and will build the **structure**, **appearance** and **functionality** of our application.
522+
For visualization, we will use an **internet browser**, that interprets **HTML** pages. We will create a new page and will build the **structure**, **appearance**, and **functionality** of our application.
689523

690524
As usual, we **create a new file**, save it with the name **Currency-Converter**, however this time we add the file extension **.html**.
691525

0 commit comments

Comments
 (0)