Advertisement
Spocoman

Easter Decoration

Oct 7th, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.05 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "bufio"
  6.     "os"
  7.     "strconv"
  8. )
  9.  
  10. func main() {
  11.     scanner := bufio.NewScanner(os.Stdin)
  12.    
  13.     scanner.Scan()
  14.     clients, _ := strconv.Atoi(scanner.Text())
  15.  
  16.     var totalSum float64
  17.     var stock string
  18.  
  19.     for i := 0; i < clients; i++ {
  20.         counter := 0
  21.         sum := 0.0
  22.        
  23.         scanner.Scan()
  24.         stock = scanner.Text()
  25.        
  26.         for stock != "Finish" {
  27.             switch stock {
  28.                 case "basket":
  29.                     sum += 1.50
  30.                 case "wreath":
  31.                     sum += 3.80
  32.                 case "chocolate bunny":
  33.                     sum += 7.00
  34.             }
  35.             counter++
  36.             scanner.Scan()
  37.             stock = scanner.Text()
  38.         }
  39.  
  40.         if counter % 2 == 0 {
  41.             sum *= 0.80
  42.         }
  43.  
  44.         totalSum += sum
  45.         fmt.Printf("You purchased %d items for %.2f leva.\n", counter, sum)
  46.     }
  47.    
  48.     fmt.Printf("Average bill per client is: %.2f leva.\n", totalSum / float64(clients))
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement