year_quarter function

This commit is contained in:
zainabdnaya 2022-08-02 00:50:43 +01:00
parent 67606b336b
commit 92e64ac14a
2 changed files with 45 additions and 40 deletions

View File

@ -1,40 +0,0 @@
## Fishandchips
### Instructions
Write a function called `Fishandchips()` Write a function that takes an integer and returns a string.
- If the number is divisible by 3, print `chips` followed by a newline `\n`.
- If the number is divisible by 2 and 3, print `fish and chips` followed by a newline `\n`.
- If is not divisible by any of 3 and 2 print newline `\n`.
### Expected function
```go
func Fishandchips(n int32) string {
}
```
### Usage
Here is a possible program to test your function :
```go
package main
func main() {
args := []int32{0, 6, 33, -3, 5, 8}
for i := 0; i < len(args); i++ {
Fishandchips(args[i])
}
}
```
And its output :
```go
fish and chips$
fish and chips$
chips$
chips$
$
$
```

View File

@ -0,0 +1,45 @@
## Y_quarter
### Instructions
Write a function called `Y_quarter()` that takes month as an integer from 1 to 12, return to which quarter of the year it belongs as an integer number.
- if the number is not between 1 and 12 return `-1`.
### Expected function
```go
func Y_quarter(month int) int {
}
```
### Usage
Here is a possible program to test your function :
```go
package main
import "fmt"
func main() {
fmt.Println(Y_quarter(2))
fmt.Println(Y_quarter(5))
fmt.Println(Y_quarter(8))
fmt.Println(Y_quarter(11))
fmt.Println(Y_quarter(13))
fmt.Println(Y_quarter(-5))
}
```
And its output :
```go
$ go run .
1
2
3
4
-1
-1
```