You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two examples were out of sync with their descriptions:
- On line 895, the equality check was for `"string"` while the example output indicated this should be `"a string"`
- On line 1085 the check was `number >= 4 && number <= 10` while the text on line 1079 said "The code is used to check if the number in the variable is greater than 4 and less than 11".
Also took a shot at the section marked with `TODO: Find a better way to translate`, hopefully it's a bit clearer now.
Copy file name to clipboardExpand all lines: data/part-1/6-conditional-statements.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ hidden: false
17
17
18
18
- get familiar with comparison and logical operators commonly used in conditional statements.
19
19
20
-
- know how to compare numbers as well as strings while remembering the equals-command for strings.
20
+
- know how to compare both numbers and strings, remembering the equals-command for strings.
21
21
22
22
- get familiar with the order of execution for a conditional statement, and know that the parsing of a conditional statement stops at the first condition whose statement evaluates to true.
23
23
@@ -61,7 +61,7 @@ A conditional statement begins with the keyword `if` followed by parentheses. An
61
61
62
62
<!-- Sulkuja seuraa lohko, joka määritellään avaavan aaltosulun `{` ja sulkevan aaltosulun `}` sisään. Lohkon sisällä oleva lähdekoodi mikäli sulkujen sisälle asetettu lauseke evaluoidaan todeksi (true). -->
63
63
64
-
The parentheses are followed by a block, which is defined inside opening-`{` and closing `}` curly brackets. The source code inside the block is executed if the expression inside the parentheses evaluates to *true*.
64
+
The parentheses are followed by a block, which is defined inside opening `{` and closing `}` curly brackets. The source code inside the block is executed if the expression inside the parentheses evaluates to *true*.
65
65
66
66
<!-- Tarkastellaan esimerkkiä, missä ehtolauseen lausekkeessa vertaillaan lukuja. -->
67
67
@@ -181,11 +181,11 @@ In Java, code is indented by four spaces or a single tab in each block. Use eith
181
181
182
182
<!-- Jatkossa ohjelmakoodi tulee sisentää oikein myös tehtävissä. Jos sisennys on väärin, ei ohjelmointiympäristö hyväksy tehtävää. -->
183
183
184
-
Going forward, program code needs to be indented correctly in exercises too. If the indentation is incorrect, the development environment will not accept the solution. You will see indentation errors highlighted yellow in the test results.
184
+
Going forward, program code needs to be indented correctly in exercises too. If the indentation is incorrect, the development environment will not accept the solution. You will see indentation errors highlighted in yellow in the test results.
185
185
186
186

187
187
188
-
The above error message says, that there should have been 8 spaces at the beginning of line 8, but there was only 2.
188
+
The above error message says that there should have been 8 spaces at the beginning of line 8, but there was only 2.
189
189
In this case we can fix the indentation by adding 6 more spaces to the beginning of line 8.
190
190
191
191
@@ -337,7 +337,7 @@ Your number is five or less!
337
337
338
338
<!-- Jos ehtolauseeseen on määritelty `else`-haara, suoritetaan else-haaran määrittelemä lohko jos ehtolauseen ehto ei ole totta. Komento `else` tulee samalle riville `if`-komennon määrittelemän lohkon lopettavan aaltosulun kanssa. -->
339
339
340
-
If an `else`-branch has been defined for the conditional statement, then the block defined by the else-branch is run if the condition of the conditional statement is not true. The `else`-command is placed on the same line as the closing bracket of the block defined by the `if`-command.
340
+
If an `else`branch has been defined for the conditional statement, then the block defined by the `else`branch is run if the condition of the conditional statement is not true. The `else`command is placed on the same line as the closing bracket of the block defined by the `if`command.
@@ -524,7 +524,7 @@ The number is greater than zero.
524
524
525
525
<!-- Yllä oleva esimerkki tulostaa merkkijonon "Luku on suurempi kuin nolla." vaikka myös ehto `luku > 2` on totta. Vertailu lopetetaan ensimmäiseen valintakäskyyn, jonka ehto on totta. -->
526
526
527
-
The example above prints the string "The number is greater than zero." even if the condition `number > 2` is true. The comparing stops at the first condition that evaluates to true.
527
+
The example above prints the string "The number is greater than zero." even if the condition `number > 2` is true. The comparison stops at the first condition that evaluates to true.
528
528
529
529
<!-- <programming-exercise name="Arvosanat ja pisteet" tmcname='osa01-Osa01_31.ArvosanatJaPisteet'> -->
530
530
<programming-exercisename="Grades and points"tmcname='part01-Part01_31.GradesAndPoints'>
@@ -892,7 +892,7 @@ Scanner reader = new Scanner(System.in);
892
892
System.out.println("Enter a string");
893
893
String input = reader.nextLine();
894
894
895
-
if (input.equals("string")) {
895
+
if (input.equals("a string")) {
896
896
System.out.println("Great! You read the instructions correctly.");
897
897
} else {
898
898
System.out.println("Missed the mark!");
@@ -918,7 +918,7 @@ Great! You read the instructions correctly.
918
918
<!-- Komento equals kirjoitetaan merkkijonomuuttujan jälkeen siten, että se kiinnitetään pisteellä vertailtavaan muuttujaan. Komennolle annetaan parametrina merkkijono, johon muuttujaa vertaillaan. Mikäli merkkijonomuuttujaa vertaillaan suoraan merkkijonoon, voi merkkijonon asettaa hipsuilla merkittynä equals-komennon sulkujen sisään. Muulloin sulkujen sisään asetetaan sen merkkijonomuuttujan nimi, johon merkkijonomuuttujan sisältämää merkkijonoa verrataan. -->
919
919
920
920
<!-- TODO: Find a better way to translate -->
921
-
The equals command is written after a string by attaching it to the string to be compared with a dot. The command is given a parameter, which is the string that the variable will be compared against. If the string variable is being directly compared with a string, then the string can be placed inside the parentheses of the equals-command within quotation marks. Otherwise, the name of the string variable that holds the string to be compared is placed inside the parentheses.
921
+
The equals command comes after the first string, attached to it with a dot. The command is given the second string as a parameter. Both the first and the second string can be either string literals, or variables containing strings.
922
922
923
923
<!-- Alla olevassa esimerkissä luetaan käyttäjältä kaksi merkkijonoa. Ensin tarkastetaan ovatko syötetyt merkkijonot samat, jonka jälkeen tarkastetaan onko syötettyjen merkkijonojen arvo "kaksi merkkijonoa". -->
924
924
@@ -1076,13 +1076,13 @@ The expression of a conditional statement may consist of multiple parts, in whic
1076
1076
1077
1077
<!-- Seuraavassa yhdistetään `&&`:lla eli ja-operaatiolla kaksi yksittäistä ehtoa. Koodilla tarkistetaan, onko muuttujassa oleva luku suurempi kuin 4 ja pienempi kuin 11, eli siis välillä 5-10: -->
1078
1078
1079
-
In the next example we combine two individual conditions using `&&`, i.e., the and-operator. The code is used to check if the number in the variable is greater than 4 and less than 11. In other words, whether it's within the range of 5-10:
1079
+
In the next example we combine two individual conditions using `&&`, i.e., the and-operator. The code is used to check if the number in the variable is greater than or equal to 5 and less than or equal to 10. In other words, whether it's within the range of 5-10:
1080
1080
1081
1081
<!-- ```java
1082
1082
System.out.println("Onkohan luku väliltä 5-10: ");
1083
1083
int luku = 7;
1084
1084
1085
-
if (luku >= 4 && luku <= 10) {
1085
+
if (luku >= 5 && luku <= 10) {
1086
1086
System.out.println("On! :)");
1087
1087
} else {
1088
1088
System.out.println("Ei ollut :(")
@@ -1143,7 +1143,7 @@ It is! :)
1143
1143
1144
1144
<!-- Seuraavassa käännetään `!` ei-operaatiolla lausekkeen `luku > 4` tulos. Ei-operaatio merkitään lauseketta ennen niin, että käännettävä lauseke rajataan suluilla, ja ei-operaatio lisätään sulkuja ennen. -->
1145
1145
1146
-
In this example we flip the result of the expression `number > 4` using `!`, i.e., the not-operator. The not-operator is notated in such a way that the expression to be flipped is wrapped in parentheses, and the not-operator is placed before the parentheses.
1146
+
In this example we flip the result of the expression `number > 4` using `!`, i.e., the not-operator. The not-operator is written in such a way that the expression to be flipped is wrapped in parentheses, and the not-operator is placed before the parentheses.
1147
1147
1148
1148
<!-- ```java
1149
1149
int luku = 7;
@@ -1443,7 +1443,7 @@ The year is a leap year.
1443
1443
</sample-output>
1444
1444
1445
1445
<!-- Vihje 1: Jollain luvulla jaollisuuden voi tarkastaa jakojäännösoperaation `%` avulla seuraavasti. -->
1446
-
Hint 1: The divisibility by a particular number can be checked using the modulo operator, aka `%`, in the following way.
1446
+
Hint 1: Divisibility by a particular number can be checked using the modulo operator, aka `%`, in the following way.
1447
1447
1448
1448
<!-- ```java
1449
1449
int luku = 5;
@@ -1479,7 +1479,7 @@ The number is not divisible by six!
1479
1479
<!-- TODO: Virhe suomenkielisessä tekstissä. "ohjelma ei ole karkausvuosi" -->
1480
1480
<!-- Vihje 2: mieti ongelmaa if, else if, else if, ... -vertailujen ketjuna ja aloita ohjelman rakentaminen tilanteesta, missä voit olla varma, että ohjelma ei ole karkausvuosi. -->
1481
1481
1482
-
Hint 2: Think of the problem as a chain of if, else if, else if, ... -comparisons, and start building the program from a situation in which you can be certain that the year is not a leap year.
1482
+
Hint 2: Think of the problem as a chain of if, else if, else if, ... comparisons, and start building the program from a situation in which you can be certain that the year is not a leap year.
0 commit comments