mirror of
https://github.com/c0de-archive/hacktoberfest-2018.git
synced 2024-12-21 21:02:40 +00:00
simple calculato or Go
This commit is contained in:
parent
306ebd4561
commit
0906c02b43
31
code/golang/gocalc/gocalc.go
Normal file
31
code/golang/gocalc/gocalc.go
Normal file
@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var num1 int64
|
||||
var num2 int64
|
||||
var action string
|
||||
|
||||
func main() {
|
||||
fmt.Println("Enter firs number:")
|
||||
fmt.Scan(&num1)
|
||||
fmt.Println("Enter second number:")
|
||||
fmt.Scan(&num2)
|
||||
fmt.Println("Enter operation('+', '-', '*' or '/'):")
|
||||
fmt.Scan(&action)
|
||||
|
||||
if action == "+" {
|
||||
fmt.Printf("%v + %v = %v\n", num1, num2, num1+num2)
|
||||
}
|
||||
if action == "-" {
|
||||
fmt.Printf(" %v - %v = %v\n", num1, num2, num1-num2)
|
||||
}
|
||||
if action == "*" {
|
||||
fmt.Printf(" %v * %v = %v\n", num1, num2, num1*num2)
|
||||
}
|
||||
if action == "/" {
|
||||
fmt.Printf(" %v / %v = %v\n", num1, num2, num1/num2)
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hi! Please enter your name...")
|
||||
var inpt string
|
||||
fmt.Scan(&inpt)
|
||||
fmt.Printf("Hello %s, welcome on Hacktoberfest!\n", inpt)
|
||||
}
|
Loading…
Reference in New Issue
Block a user