# Review problems 3

<!--
- Write a function with arguments and return value
-->
:::{activity} AdultCorpulenceIndex
[Corpulence index](https://en.wikipedia.org/wiki/Corpulence_index) is a measure of leanness:

$ \mathrm{CI} = \frac{\mathrm{mass}}{\mathrm{height}^3} $

Write a program that calculates corpulence index (CI) for **adults** and output the corresponding [category](https://en.wikipedia.org/wiki/Corpulence_index#Categories).

Requirements:
- use constant variables for the CI category ranges, e.g., `const int underWeightMax = 11`.
- you must define a function called `ci()` for calculating the CI.
- CI must be rounded to two digits after the decimal dot when printed on the console
- use first an `if-else` statement
  - if your programs works, then comment it out and solve the problem with a `switch` statement

```text
Enter mass in kg
80
Enter height in m
1.70
Adults corpulence index of 16.28 means: overweight
```

```{dropdown} Hint
- Section {ref}`creating-functions`
- For rounding, see section {ref}`math-expressions`
- Section {ref}`if-else`
- Section {ref}`switch`
  - you can also use comparison operators in case statements, e.g., `case < underweightMax`
```
:::


<!--
- functions
- loops
- lists for organizing the constants
-->
:::{activity} ChocolateMachineLeasing
You work at a company that manufactures machines for chocolate and confectionary production. In recent years the machines become very complex so your company is transitioning to a leasing model, where your company does not only sell but also provide maintenance that includes software updates to the machines. You are asked to write a tool that calculates example scenarios according to the costs below:

Example run:
```text
Select machine
0. Tempering machine
1. Aeration machine
2. Enrober
1
Enter downtime in hours
-1
Downtime must be a non-negative integer. Try again.
2
Enter leasing time in months
10
Total cost: 74800 EUR
```

- Base lease fee
  - [tempering machine](https://en.wikipedia.org/wiki/Tempered_chocolate): 5000 EUR/month
  - [aeration machine](https://en.wikipedia.org/wiki/Aerated_chocolate): 7500 EUR/month
  - [enrober](https://en.wikipedia.org/wiki/Enrober): 6200 EUR/month
- Downtime penalty
  - if a machine is down for more than 1h in a month, then the customer receives 100 EUR/hour compensation for each downtime hour.
  - The compensation cannot be more than the total base lease fee.
- Long-term discounts
  - more than 12 months: 5%
  - more than 24 months: 10%
  
Requirements:
- your program contains the function with the following signature:

  ```{literalinclude} ../code-wi/ChocolateMachineLeasing.cs
  :language: cs
  :start-at: decimal LeasingCost
  :end-before: {
  ```
  
  Example outputs:
  ```cs
  LeasingCost(0, 0, 1);
  LeasingCost(2, 0, 1);
  LeasingCost(2, 1, 1);
  LeasingCost(2, 2, 1);
  LeasingCost(2, 0, 2);
  LeasingCost(2, 200, 2);
  LeasingCost(2, 0, 20);
  LeasingCost(2, 0, 30);
  ```
  Output:
  ```text
  5000
  6200
  6200
  6000
  12400
  0
  95000.00
  135000.0
  ```

```{dropdown} Hint
- Section {ref}`creating-functions`
- Section {ref}`list`
- Section {ref}`while`
- Section {ref}`while`
```
:::

Review: {ref}`currency-converter-with-gui-code`.

:::{activity} OOPBasedTodoApp
Let's implement a simple OOP-based To-do app. It must have the following classes and methods:

```{mermaid}
classDiagram
    class TodoItem {
        +string action
        +bool done
    }

    class TodoList {
        +List~TodoItem~ Items
        +Add(TodoItem item)
        +getTodos() List~TodoItem~
        +MarkActionDone(string action)
    }

    TodoList o-- TodoItem
```

Use the following code to test your app:

```{literalinclude} ../code/OOPBasedTodoApp.cs
:language: cs
:end-before: public class
```


```{dropdown} Hint
- Section {ref}`creating-functions`
- Section {ref}`class-diagram`
- Section {ref}`printable-classes`
```
:::