mirror of https://github.com/01-edu/public.git
Browse Source
* docs(quarterofayear): add README.md for new go exam exercise * docs(quarterofayear): instructions upgrade --------- Co-authored-by: Tiago Collot <>pull/1513/head
Tiago Collot
1 year ago
committed by
GitHub
1 changed files with 50 additions and 0 deletions
@ -0,0 +1,50 @@ |
|||||||
|
## quarterofayear |
||||||
|
|
||||||
|
### Instructions |
||||||
|
|
||||||
|
Write a function `QuarterOfAYear()` that takes an `int`, from 1 to 12, as an argument and returns an `int` with the respective quarter of the year to which it belongs. |
||||||
|
|
||||||
|
- If the number is not between 1 and 12 return `-1`. |
||||||
|
|
||||||
|
|
||||||
|
### Expected function |
||||||
|
|
||||||
|
```go |
||||||
|
func QuarterOfAYear(month int) int { |
||||||
|
|
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
### Usage |
||||||
|
|
||||||
|
Here is a possible program to test your function: |
||||||
|
|
||||||
|
```go |
||||||
|
package main |
||||||
|
|
||||||
|
import ( |
||||||
|
"fmt" |
||||||
|
"piscine" |
||||||
|
) |
||||||
|
|
||||||
|
func main() { |
||||||
|
fmt.Println(piscine.QuarterOfAYear(2)) |
||||||
|
fmt.Println(piscine.QuarterOfAYear(5)) |
||||||
|
fmt.Println(piscine.QuarterOfAYear(9)) |
||||||
|
fmt.Println(piscine.QuarterOfAYear(11)) |
||||||
|
fmt.Println(piscine.QuarterOfAYear(13)) |
||||||
|
fmt.Println(piscine.QuarterOfAYear(-5)) |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
And its output: |
||||||
|
|
||||||
|
```console |
||||||
|
$ go run . |
||||||
|
1 |
||||||
|
2 |
||||||
|
3 |
||||||
|
4 |
||||||
|
-1 |
||||||
|
-1 |
||||||
|
``` |
Loading…
Reference in new issue