# Review problems

This week we will review part of what we have seen before and will write various small programs.


Requirements:
1. Create a single solution and for each program, [create a separate project](creating-multiple-projects-in-a-single-solution).
1. Each `Project Name` must be named after the activity names, e.g., `ArithmeticOperations`.
1. In your README describe in a single sentence what each program does.

<!--
- use `Console.{Write,Read}Line()`
- differentiate between `string` and numbers
- use `int.TryParse()` or `Convert
-->
:::{activity} ArithmeticOperations
Write a program that reads two integers from the console and then displays:

1. sum
2. product
3. difference
4. quotient
5. remainder

Assume that the user will always provide integer numbers.

Example:
```text
Enter first integer
2
Enter second integer
5
Result:
7
10
-3
0
2
```

```{dropdown} Hint
- Section {ref}`data-input-on-the-console`
- Section {ref}`arguments-and-return-value-in-functions`
- Section {ref}`math-expressions`
```
:::

<!--
- user input & output
- use modulo operator
- use decimal numbers
-->
:::::{activity} MultiplesOfNumbers
Write a console program that determines whether a given number is multiples of the second given number. Use the modulo operator.

::::{grid} 2
:::{grid-item} Example 1
```text
Enter dividend
34.1
Enter divisor
0.1
Multiples
```
:::
:::{grid-item} Example 2
```text
Enter dividend
12
Enter divisor
5
Not multiples
```
:::
::::

```{dropdown} Hint
- Section {ref}`math-expressions`
- Section {ref}`if-else`
```
:::::

<!--
- use foreach to break a sequence down
- use a variable to gradually create the sum in a foreach loop 
-->
:::{activity} DigitSumForeach
Read an integer from the console and calculate the sum of its digits.

Steps:
1. Loop over the characters of the input string
1. Convert each character to a string and try to parse each character-string as an integer.
1. Create a sum of all these integers.

Example:
```text
Enter an integer
1090
Sum: 10
```

```{dropdown} Hint
- Section {ref}`conversion-between-datatypes`
- Section {ref}`foreach`
```
:::

<!--
- Translate a flowchart into code
- Differentiate between decimal and integer division
- Use a control loop
-->
:::{activity} DigitSumModulo
Read an integer from the console and calculate the sum of its digits using the following algorithm:

```{mermaid}
graph 
s(start)
read[read number]
init[initialize sum]
loop{is number > 0?}
  mod[get the least significant digit of number using modulo]
  add[add the remainder to the sum]
  div[divide number by 10]
e(end)
  
s --> read --> init --> loop --yes--> mod --> add --> div
div --> loop
loop --noo--> e
```

Example:
```text
Enter an integer
123
Sum: 6
```

```{dropdown} Hint
- Section {ref}`while`
```
:::

<!--
Use and combine boolean variables to change the control flow
-->
:::::{activity} DecisionBasedOnBooleans
Should you stay or should you go? You cannot decide from the top of your head whether you want to go to the lecture or not. You came up with the following criteria. If all off the criteria is fulfilled then you will go to the lecture.

1. Lecture topic is interesting.
1. At least one of your friends will join or you have problems with the assignment.

Write a program that prompts you **three** questions and gives a recommendation.

::::{grid} 2
:::{grid-item}
```text
Is the lecture topic interesting?
y
Does one of your friends join?
n
Do you have problems with the assignment?
y
Go. ✅
```
:::
:::{grid-item}
```
Is the lecture topic interesting?
n
Does one of your friends join?
y
Do you have problems with the assignment?
y
Stay. ❌
```
:::
::::

```{dropdown} Hint
- Section {ref}`boolean-logic`
```
:::::


:::{activity} SentenceFromWords
Write a program that puts input words together into a sentence and prints the sentence.

```
Enter words of a sentence one by one including punctuation:
I
go
home
now.
I go home now.
```

```{dropdown} Hint
- Section {ref}`while`
- Section {ref}`strings`
```
:::::
:::

