Skip to content

Commit 64cbb4e

Browse files
authored
Merge pull request rage#22 from rage/exercises
Exercises
2 parents a3e3e67 + 8b5cfe2 commit 64cbb4e

File tree

6 files changed

+143
-802
lines changed

6 files changed

+143
-802
lines changed

data/osa-1/6-conditional-statements.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ The number is greater than zero.
516516
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.
517517

518518
<!-- <programming-exercise name="Arvosanat ja pisteet" tmcname='osa01-Osa01_31.ArvosanatJaPisteet'> -->
519-
<programming-exercise name="Grades and points" tmcname='osa01-Osa01_31.ArvosanatJaPisteet'>
519+
<programming-exercise name="Grades and points" tmcname='Part01-Part01_31.GradesAndPoints'>
520520

521521
<!-- Alla oleva taulukko kuvaa erään kurssin arvosanan muodostumista. Tee ohjelma, joka ilmoittaa kurssiarvosanan annetun taulukon mukaisesti. -->
522522

@@ -1474,21 +1474,26 @@ if (number % 4 != 0) {
14741474
<!-- <programming-exercise name='Lahjaverolaskuri' tmcname='osa01-Osa01_37.Lahjaverolaskuri'> -->
14751475
<programming-exercise name='Gift tax' tmcname='part01-Part01_37.GiftTax'>
14761476

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.*
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.*
14781479

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)):
14801482

1481-
| Lahja | Vero alarajalla | Veroprosentti ylimenevästä |
1482-
|-----------------------|------------------|-----------------------------|
1483-
| 5 000 -- 25 000 | 100 | 8 |
1484-
| 25 000 -- 55 000 | 1 700 | 10 |
1485-
| 55 000 -- 200 000 | 4 700 | 12 |
1486-
| 200 000 -- 1 000 000 | 22 100 | 15 |
1487-
| 1 000 000 -- | 142 100 | 17 |
1483+
| Value of gift | Tax at the lower limit | Tax rate(%) for exceeding part |
1484+
|-----------------------|-------------------------|---------------------------------|
1485+
| 5 000 -- 25 000 | 100 | 8 |
1486+
| 25 000 -- 55 000 | 1 700 | 10 |
1487+
| 55 000 -- 200 000 | 4 700 | 12 |
1488+
| 200 000 -- 1 000 000 | 22 100 | 15 |
1489+
| 1 000 000 -- | 142 100 | 17 |
14881490

1489-
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).
14901493

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.
1496+
This is how the program should work:
14921497

14931498
<sample-output>
14941499

data/osa-2/1-ongelmia-ja-ratkaisumalleja.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ public class Program {
231231
}
232232
```
233233

234-
<programming-exercise name='Toiseen potenssiin' tmcname='osa02-Osa02_01.ToiseenPotenssiin'>
234+
<programming-exercise name='Squared' tmcname='part02-Part02_01.Squared'>
235235

236236
<!-- Kirjoita ohjelma, joka lukee käyttäjältä kokonaisluvun ja tulostaa luvun korotettuna toiseen potenssin eli luvun kerrottuna itsellään. -->
237237

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.
239239

240240
<sample-output>
241241

@@ -261,7 +261,7 @@ Write a program, that reads an integer from the user input, and then prints the
261261
</programming-exercise>
262262

263263

264-
<programming-exercise name='Summan neliöjuuri' tmcname='osa02-Osa02_02.SummanNeliojuuri'>
264+
<programming-exercise name='Square root of sum' tmcname='part02-Part02_02_SquareRootOfSum'>
265265

266266
<!-- Kirjoita ohjelma, joka lukee käyttäjältä kaksi kokonaislukua ja tulostaa lukujen summan neliöjuuren. Ohjelman ei tarvitse käsitellä negatiivisia lukuja. -->
267267
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.
@@ -276,8 +276,8 @@ System.out.println(neliojuuri);
276276
``` -->
277277

278278
```java
279-
int value = 42;
280-
double squareRoot = Math.sqrt(value);
279+
int number = 42;
280+
double squareRoot = Math.sqrt(number);
281281
System.out.println(squareRoot);
282282
```
283283

@@ -461,7 +461,7 @@ public class Program {
461461
```
462462

463463

464-
<programming-exercise name='Itseisarvo' tmcname='osa02-Osa02_03.Itseisarvo'>
464+
<programming-exercise name='Absolute value' tmcname='part02-Part02_03.AbsoluteValue'>
465465

466466
<!-- 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. -->
467467

data/osa-2/2-toistaminen.md

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -662,52 +662,54 @@ Total of ones: 2
662662
</sample-output>
663663

664664

665-
<programming-exercise name="Lukujen lukumäärä" tmcname='osa02-Osa02_08.LukujenLukumaara'>
665+
<programming-exercise name="Number of numbers" tmcname="Part02-Part02_08.NumberOfNumbers">
666666

667667
<!-- 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ää. -->
668668
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.
669669

670670
<!-- Ohjelman tulostusesimerkki: -->
671671
Example output of the program:
672+
672673
<sample-output>
673674

674-
Insert a number
675+
Give a number:
675676
**5**
676-
Insert a number
677+
Give a number:
677678
**22**
678-
Insert a number
679+
Give a number:
679680
**9**
680-
Insert a number
681+
Give a number:
681682
**-2**
682-
Insert a number
683+
Give a number:
683684
**0**
684-
Numbers in total 4
685+
Number of numbers: 4
685686

686687
</sample-output>
687688

688689
</programming-exercise>
689690

690691

691-
<programming-exercise name="Negatiivisten lukujen lukumäärä" tmcname='osa02-Osa02_09.NegatiivistenLukujenMaara'>
692+
<programming-exercise name="Number of negative numbers" tmcname='Part02-Part02_09.NumberOfNegativeNumbers'>
692693

693694
<!-- 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ää. -->
694695
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.
695696

696697
<!-- Ohjelman tulostusesimerkki: -->
697698
Example output of the program:
699+
698700
<sample-output>
699701

700-
Insert a number
702+
Give a number:
701703
**5**
702-
Insert a number
704+
Give a number:
703705
**22**
704-
Insert a number
706+
Give a number:
705707
**9**
706-
Insert a number
708+
Give a number:
707709
**-2**
708-
Insert a number
710+
Give a number:
709711
**0**
710-
The total of negative numbers 1
712+
Number of negative numbers: 1
711713

712714
</sample-output>
713715

@@ -716,26 +718,27 @@ The total of negative numbers 1
716718
<!-- 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. -->
717719
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.
718720

719-
<programming-exercise name="Lukujen summa" tmcname='osa02-Osa02_10.LukujenSumma'>
721+
<programming-exercise name="Sum of numbers" tmcname='part02-Part02_10.SumOfNumbers'>
720722

721723
<!-- 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. -->
722724
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.
723725

724726
<!-- Ohjelman tulostusesimerkki: -->
725727
Example output of the program:
728+
726729
<sample-output>
727730

728-
Input a number
731+
Give a number:
729732
**5**
730-
Input a number
733+
Give a number:
731734
**22**
732-
Input a number
735+
Give a number:
733736
**9**
734-
Input a number
737+
Give a number:
735738
**-2**
736-
Input a number
739+
Give a number:
737740
**0**
738-
The sum of the numbers 34
741+
Sum of the numbers: 34
739742

740743
</sample-output>
741744

@@ -747,10 +750,10 @@ TODO: esimerkki toistolauseesta, missä kaksi muuttujaa
747750

748751

749752

750-
<programming-exercise name="Lukujen lukumäärä ja summa" tmcname='osa02-Osa02_11.LukumaaraJaSumma'>
753+
<programming-exercise name="Number and sum of numbers" tmcname='part02-Part02_11.NumberAndSumOfNumbers'>
751754

752755
<!-- 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.
754757

755758
<!-- _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._ -->
756759
_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:
760763

761764
<sample-output>
762765

763-
Input a number
766+
Give a number:
764767
**5**
765-
Input a number
768+
Give a number:
766769
**22**
767-
Input a number
770+
Give a number:
768771
**9**
769-
Input a number
772+
Give a number:
770773
**-2**
771-
Input a number
774+
Give a number:
772775
**0**
773-
Numbers in total 4
774-
The sum of numbers 34
776+
Number of numbers: 4
777+
Sum of the numbers: 34
775778

776779
</sample-output>
777780

778781
</programming-exercise>
779782

780783

781-
<programming-exercise name="Lukujen keskiarvo" tmcname='osa01-Osa02_12.LukujenKeskiarvo'>
784+
<programming-exercise name="Average of numbers" tmcname='part02-Part02_12.AverageOfNumbers'>
782785

783786
<!-- 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.
785788

786789
<!-- _Lukujen keskiarvo saadaan jakamalla lukujen summa lukujen lukumäärällä_. -->
787790
_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:
791794

792795
<sample-output>
793796

794-
Insert a number
797+
Give a number:
795798
**5**
796-
Insert a number
799+
Give a number:
797800
**22**
798-
Insert a number
801+
Give a number:
799802
**9**
800-
Insert a number
803+
Give a number:
801804
**-2**
802-
Insert a number
805+
Give a number:
803806
**0**
804-
The average of numbers 8.5
807+
Average of the numbers: 8.5
805808

806809
</sample-output>
807810

808811
</programming-exercise>
809812

810813

811-
<programming-exercise name='Positiivisten lukujen keskiarvo' tmcname='osa02-Osa02_13.PositiivistenLukujenKeskiarvo'>
814+
<programming-exercise name='Average of positive numbers' tmcname='part02-Part02_13.AverageOfPositiveNumbers'>
812815

813816
<!-- 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. -->
814817
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
834837
<sample-output>
835838

836839
**0**
837-
The computation of average is impossible
840+
Cannot calculate the average
838841

839842
</sample-output>
840843

0 commit comments

Comments
 (0)