Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var product, town string
- fmt.Scanln(&product)
- fmt.Scanln(&town)
- var quantity float64
- fmt.Scanln(&quantity)
- var price = 0.0
- if (town == "Sofia") {
- if (product == "coffee") {
- price = 0.50
- } else if (product == "water") {
- price = 0.80
- } else if (product == "beer") {
- price = 1.20
- } else if (product == "sweets") {
- price = 1.45
- } else if (product == "peanuts") {
- price = 1.60
- }
- } else if (town == "Plovdiv") {
- if (product == "coffee") {
- price = 0.40
- } else if (product == "water") {
- price = 0.70
- } else if (product == "beer") {
- price = 1.15
- } else if (product == "sweets") {
- price = 1.30
- } else if (product == "peanuts") {
- price = 1.50
- }
- } else if (town == "Varna") {
- if (product == "coffee") {
- price = 0.45
- } else if (product == "water") {
- price = 0.70
- } else if (product == "beer") {
- price = 1.10
- } else if (product == "sweets") {
- price = 1.35
- } else if (product == "peanuts") {
- price = 1.55
- }
- }
- fmt.Println(price * quantity)
- }
- ИЛИ:
- package main
- import "fmt"
- func main() {
- var product, town string
- fmt.Scanln(&product)
- fmt.Scanln(&town)
- var quantity float64
- fmt.Scanln(&quantity)
- var price = 0.0
- switch (town) {
- case "Sofia":
- switch (product) {
- case "coffee":
- price = 0.50
- case "water":
- price = 0.80
- case "beer":
- price = 1.20
- case "sweets":
- price = 1.45
- case "peanuts":
- price = 1.60
- }
- case "Plovdiv":
- switch (product) {
- case "coffee":
- price = 0.40
- case "water":
- price = 0.70
- case "beer":
- price = 1.15
- case "sweets":
- price = 1.30
- case "peanuts":
- price = 1.50
- }
- case "Varna":
- switch (product) {
- case "coffee":
- price = 0.45
- case "water":
- price = 0.70
- case "beer":
- price = 1.10
- case "sweets":
- price = 1.35
- case "peanuts":
- price = 1.55
- }
- }
- fmt.Println(price * quantity)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement