Advertisement
Spocoman

Club

Oct 5th, 2024
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.86 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.   "fmt"
  5.   "bufio"
  6.   "os"
  7.   "strconv"
  8. )
  9.  
  10. func main() {
  11.     var neededSum, currentSum, income float64
  12.     fmt.Scanln(&neededSum)
  13.    
  14.     scanner := bufio.NewScanner(os.Stdin)
  15.     scanner.Scan()
  16.     cocktailName := scanner.Text()
  17.  
  18.     for income < neededSum && cocktailName != "Party!" {
  19.         scanner.Scan()
  20.         cocktailCount, _ := strconv.Atoi(scanner.Text())
  21.         currentSum = float64(cocktailCount) * float64(len(cocktailName))
  22.         if int(currentSum) % 2 == 1 {
  23.             currentSum *= 0.75
  24.         }
  25.         income += currentSum
  26.         scanner.Scan()
  27.         cocktailName = scanner.Text()
  28.     }
  29.  
  30.     if neededSum > income {
  31.         fmt.Printf("We need %.2f leva more.\n", neededSum - income)
  32.     } else {
  33.         fmt.Println("Target acquired.")
  34.     }
  35.     fmt.Printf("Club income - %.2f leva.\n", income)
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement