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
Copy file name to clipboardExpand all lines: data/osa-1/6-conditional-statements.md
+17-12Lines changed: 17 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -516,7 +516,7 @@ The number is greater than zero.
516
516
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.
517
517
518
518
<!-- <programming-exercise name="Arvosanat ja pisteet" tmcname='osa01-Osa01_31.ArvosanatJaPisteet'> -->
519
-
<programming-exercisename="Grades and points"tmcname='osa01-Osa01_31.ArvosanatJaPisteet'>
519
+
<programming-exercisename="Grades and points"tmcname='Part01-Part01_31.GradesAndPoints'>
520
520
521
521
<!-- Alla oleva taulukko kuvaa erään kurssin arvosanan muodostumista. Tee ohjelma, joka ilmoittaa kurssiarvosanan annetun taulukon mukaisesti. -->
[https://www.vero.fi/henkiloasiakkaat/omaisuus/lahja/](https://www.vero.fi/henkiloasiakkaat/omaisuus/lahja/): *Lahja tarkoittaa sitä, että omaisuus siirtyy toiselle henkilölle ilman korvausta. Lahjasta pitää maksaa lahjaveroa, jos samalta lahjanantajalta saatujen lahjojen arvo on kolmen vuoden aikana 5 000 euroa tai enemmän.*
1477
+
<!-- [https://www.vero.fi/henkiloasiakkaat/omaisuus/lahja/](https://www.vero.fi/henkiloasiakkaat/omaisuus/lahja/): *Lahja tarkoittaa sitä, että omaisuus siirtyy toiselle henkilölle ilman korvausta. Lahjasta pitää maksaa lahjaveroa, jos samalta lahjanantajalta saatujen lahjojen arvo on kolmen vuoden aikana 5 000 euroa tai enemmän.* -->
1478
+
[https://www.vero.fi/en/individuals/property/gifts/](https://www.vero.fi/en/individuals/property/gifts/): *A gift is a transfer of property to another person against no compensation or payment. If the total value of the gifts you receive from the same donor in the course of 3 years is €5,000 or more, you must pay gift tax.*
1478
1479
1479
-
Kun lahja tulee lähimmiltä sukulaisilta, lahjaveron määrä määräytyy seuraavan taulukon mukaan (lähde [vero.fi](https://www.vero.fi/henkiloasiakkaat/omaisuus/lahja/lahjaverolaskuri/#lahjaverotaulukot)):
1480
+
<!-- Kun lahja tulee lähimmiltä sukulaisilta, lahjaveron määrä määräytyy seuraavan taulukon mukaan (lähde [vero.fi](https://www.vero.fi/henkiloasiakkaat/omaisuus/lahja/lahjaverolaskuri/#lahjaverotaulukot)): -->
1481
+
When a gift is given by a close relative or a family member, the amount of gift tax is determined by the following table (source [vero.fi](https://www.vero.fi/en/individuals/property/gifts/gift-tax-calculator/#gifttaxtables)):
1480
1482
1481
-
|Lahja | Vero alarajalla | Veroprosentti ylimenevästä|
Esimerkiksi 6000 euron lahjasta tulee maksaa veroa 180 euroa (100 + (6000-5000) * 0.08), ja 75000 euron lahjasta tulee maksaa veroa 7100 euroa (4700 + (75000-55000) * 0.12).
1491
+
<!-- Esimerkiksi 6000 euron lahjasta tulee maksaa veroa 180 euroa (100 + (6000-5000) * 0.08), ja 75000 euron lahjasta tulee maksaa veroa 7100 euroa (4700 + (75000-55000) * 0.12). -->
1492
+
For example 6000€ gift implies 180€ of gift tax (100 + (6000-5000)*0.08), and 75000€ gift implies 7100€ of gift tax (4700 + (75000-55000) * 0.12).
1490
1493
1491
-
Tee ohjelma, joka laskee lahjaveron lähimmiltä sukulaisilta annetulle lahjalle. Alla on muutama esimerkki ohjelman toiminnasta.
1494
+
<!-- Tee ohjelma, joka laskee lahjaveron lähimmiltä sukulaisilta annetulle lahjalle. Alla on muutama esimerkki ohjelman toiminnasta. -->
1495
+
Write a program that calculates the gift tax for a gift from a close relative or a family member.
<!-- Kirjoita ohjelma, joka lukee käyttäjältä kokonaisluvun ja tulostaa luvun korotettuna toiseen potenssin eli luvun kerrottuna itsellään. -->
237
237
238
-
Write a program, that reads an integer from the user input, and then prints the second power of the given integer, i.e. the integer multiplied by itself.
238
+
Write a program that reads an integer from the user input, and then prints the second power of the given integer, i.e. the integer multiplied by itself.
239
239
240
240
<sample-output>
241
241
@@ -261,7 +261,7 @@ Write a program, that reads an integer from the user input, and then prints the
<programming-exercisename='Square root of sum'tmcname='part02-Part02_02_SquareRootOfSum'>
265
265
266
266
<!-- Kirjoita ohjelma, joka lukee käyttäjältä kaksi kokonaislukua ja tulostaa lukujen summan neliöjuuren. Ohjelman ei tarvitse käsitellä negatiivisia lukuja. -->
267
267
Write a program that reads two integers from the user input, and then prints the square root of the sum of the given integers. The program doesn't need to work with negative values.
<!-- Kirjoita ohjelma, joka lukee käyttäjältä kokonaisluvun. Mikäli luku on pienempi kuin 0, ohjelma tulostaa luvun kerrottuna luvulla -1. Muulloin ohjelma tulostaa käyttäjän syöttämän luvun. Alla on muutamia esimerkkejä ohjelman odotetusta toiminnasta. -->
<programming-exercisename="Number of numbers"tmcname="Part02-Part02_08.NumberOfNumbers">
666
666
667
667
<!-- Kirjoita ohjelma, joka lukee käyttäjältä lukuja kunnes käyttäjä syöttää luvun 0. Tämän jälkeen ohjelman tulee tulostaa syötettyjen lukujen lukumäärän. Syötteen loppumisesta kertovaa nollaa ei tule laskea osaksi lukujen lukumäärää. -->
668
668
Write a program that reads user inputs until user inputs a number 0. After this the program prints the amount of inputted numbers. The inputted zero, which is used to exit the loop, does not count as an inputted number.
<programming-exercisename="Number of negative numbers"tmcname='Part02-Part02_09.NumberOfNegativeNumbers'>
692
693
693
694
<!-- Kirjoita ohjelma, joka lukee käyttäjältä lukuja kunnes käyttäjä syöttää luvun 0. Tämän jälkeen ohjelman tulee tulostaa syötteessä olleiden negatiivisten lukujen lukumäärän. Syötteen loppumisesta kertovaa nollaa ei tule laskea osaksi lukujen lukumäärää. -->
694
695
Write a program that reads numbers until the user inputs a number 0. After this the program prints the amount of negative numbers inputted. The inputted zero, which is used to exit the loop, does not count as an inputted number.
695
696
696
697
<!-- Ohjelman tulostusesimerkki: -->
697
698
Example output of the program:
699
+
698
700
<sample-output>
699
701
700
-
Insert a number
702
+
Give a number:
701
703
**5**
702
-
Insert a number
704
+
Give a number:
703
705
**22**
704
-
Insert a number
706
+
Give a number:
705
707
**9**
706
-
Insert a number
708
+
Give a number:
707
709
**-2**
708
-
Insert a number
710
+
Give a number:
709
711
**0**
710
-
The total of negative numbers 1
712
+
Number of negative numbers: 1
711
713
712
714
</sample-output>
713
715
@@ -716,26 +718,27 @@ The total of negative numbers 1
716
718
<!-- Edellä olevissa tehtävissä tehdyt ohjelmat ovat lukeneet käyttäjältä syötettä ja pitäneet kirjaa tietynlaisten lukujen lukumäärästä. Seuraavassa tehtävässä kaivattu lukujen summa ei oikeastaan juurikaan poikkea edellisistä tehtävistä -- nyt sen sijaan, että pidät kirjaa lukujen lukumäärästä eli lisäät lukumäärään luvun aina 1, lisäätkin "lukumäärään" eli summaan käyttäjän syöttämän luvun. -->
717
719
The previously programs done in previous exercises have read user inputs and kept track about certain types of numbers. In the next exercise the sum of numbers is no different --- this time you will keep track of numbers, which means that instead of adding one the amount of numbers, you add the number to the sum.
<programming-exercisename="Sum of numbers"tmcname='part02-Part02_10.SumOfNumbers'>
720
722
721
723
<!-- Kirjoita ohjelma, joka lukee käyttäjältä lukuja kunnes käyttäjä syöttää luvun 0. Tämän jälkeen ohjelman tulee tulostaa syötettyjen lukujen summan. Syötteen loppumisesta kertovaa nollaa ei tarvitse osaksi lukujen summaa, vaikkei siitä tässä tapauksessa oikeastaan haittaakaan ole. -->
722
724
Write a program that reads numbers from the user until the user inputs a number 0. After this the program outputs the sum of the numbers. The number zero does not need to be added to the sum albeit it does not change the results.
723
725
724
726
<!-- Ohjelman tulostusesimerkki: -->
725
727
Example output of the program:
728
+
726
729
<sample-output>
727
730
728
-
Input a number
731
+
Give a number:
729
732
**5**
730
-
Input a number
733
+
Give a number:
731
734
**22**
732
-
Input a number
735
+
Give a number:
733
736
**9**
734
-
Input a number
737
+
Give a number:
735
738
**-2**
736
-
Input a number
739
+
Give a number:
737
740
**0**
738
-
The sum of the numbers 34
741
+
Sum of the numbers: 34
739
742
740
743
</sample-output>
741
744
@@ -747,10 +750,10 @@ TODO: esimerkki toistolauseesta, missä kaksi muuttujaa
747
750
748
751
749
752
750
-
<programming-exercisename="Lukujen lukumäärä ja summa"tmcname='osa02-Osa02_11.LukumaaraJaSumma'>
753
+
<programming-exercisename="Number and sum of numbers"tmcname='part02-Part02_11.NumberAndSumOfNumbers'>
751
754
752
755
<!-- Kirjoita ohjelma, joka lukee käyttäjältä lukuja kunnes käyttäjä syöttää luvun 0. Tämän jälkeen ohjelman tulee tulostaa syötettyjen lukujen lukumäärä ja summan. Syötteen loppumisesta kertovaa nollaa ei tule ottaa huomioon lukumäärässä tai summassa. -->
753
-
Write a number that asks user for input until the user inputs 0. After this the program prints the amount of numbers inputted and the sum of the numbers. The number zero does not need to be added to the sum albeit it does not change the results.
756
+
Write a program that asks user for input until the user inputs 0. After this the program prints the amount of numbers inputted and the sum of the numbers. The number zero does not need to be added to the sum albeit it does not change the results.
754
757
755
758
<!-- _Tarvitset tässä kaksi muuttujaa tiedon säilömiseen. Käytä toista muuttujaa lukujen lukumäärän säilömiseen ja toista muuttujaa lukujen summan laskemiseen._ -->
756
759
_You need two variables to keep track of the information. Use one for keeping track of the numbers inputted and other for keeping track of the sum_
@@ -760,28 +763,28 @@ Example output of the program:
<programming-exercisename="Average of numbers"tmcname='part02-Part02_12.AverageOfNumbers'>
782
785
783
786
<!-- Kirjoita ohjelma, joka lukee käyttäjältä lukuja kunnes käyttäjä syöttää luvun 0. Tämän jälkeen ohjelman tulee tulostaa syötettyjen lukujen keskiarvo. Syötteen loppumisesta kertovaa nollaa ei tule ottaa huomioon keskiarvon laskemisessa. Voit olettaa, että käyttäjä syöttää aina vähintään yhden luvun. -->
784
-
Write a number that asks user for input until the user inputs 0. After this, the program prints the average of the numbers. The number zero does not need to be counted to the average. You may assume that the user inputs atleast one number.
787
+
Write a program that asks user for input until the user inputs 0. After this, the program prints the average of the numbers. The number zero does not need to be counted to the average. You may assume that the user inputs atleast one number.
785
788
786
789
<!-- _Lukujen keskiarvo saadaan jakamalla lukujen summa lukujen lukumäärällä_. -->
787
790
_The average of the numbrs can be computer by dividing the sum of numbers with the amount of the numbers_
@@ -791,24 +794,24 @@ Example output of the program:
<programming-exercisename='Average of positive numbers'tmcname='part02-Part02_13.AverageOfPositiveNumbers'>
812
815
813
816
<!-- Kirjoita ohjelma, joka lukee käyttäjältä kokonaislukuja kunnes käyttäjä syöttää luvun 0. Tämän jälkeen ohjelma tulostaa syötteessä esiintyneiden positiivisten (eli nollaa suurempien lukujen) keskiarvon. -->
814
817
Write a number that asks user for input until the user inputs 0.
@@ -834,7 +837,7 @@ Below a few examples of the programs output
0 commit comments