Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "bufio"
- "os"
- "strconv"
- )
- func main() {
- scanner := bufio.NewScanner(os.Stdin)
- scanner.Scan()
- clients, _ := strconv.Atoi(scanner.Text())
- var totalSum float64
- var stock string
- for i := 0; i < clients; i++ {
- counter := 0
- sum := 0.0
- scanner.Scan()
- stock = scanner.Text()
- for stock != "Finish" {
- switch stock {
- case "basket":
- sum += 1.50
- case "wreath":
- sum += 3.80
- case "chocolate bunny":
- sum += 7.00
- }
- counter++
- scanner.Scan()
- stock = scanner.Text()
- }
- if counter % 2 == 0 {
- sum *= 0.80
- }
- totalSum += sum
- fmt.Printf("You purchased %d items for %.2f leva.\n", counter, sum)
- }
- fmt.Printf("Average bill per client is: %.2f leva.\n", totalSum / float64(clients))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement