From 29c573d483d0ad485c448271f623700ae1e04090 Mon Sep 17 00:00:00 2001 From: Tiago Collot Date: Tue, 20 Jun 2023 11:59:44 +0100 Subject: [PATCH] DEV-3378-new-go-exercise-quarterofayear (#1525) * docs(quarterofayear): add README.md for new go exam exercise * docs(quarterofayear): instructions upgrade --------- Co-authored-by: Tiago Collot <> --- subjects/quarterofayear/README.md | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 subjects/quarterofayear/README.md diff --git a/subjects/quarterofayear/README.md b/subjects/quarterofayear/README.md new file mode 100644 index 000000000..2ab8cfe5b --- /dev/null +++ b/subjects/quarterofayear/README.md @@ -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 +```