Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "bufio"
- "os"
- "strconv"
- )
- func main() {
- var neededSum, currentSum, income float64
- fmt.Scanln(&neededSum)
- scanner := bufio.NewScanner(os.Stdin)
- scanner.Scan()
- cocktailName := scanner.Text()
- for income < neededSum && cocktailName != "Party!" {
- scanner.Scan()
- cocktailCount, _ := strconv.Atoi(scanner.Text())
- currentSum = float64(cocktailCount) * float64(len(cocktailName))
- if int(currentSum) % 2 == 1 {
- currentSum *= 0.75
- }
- income += currentSum
- scanner.Scan()
- cocktailName = scanner.Text()
- }
- if neededSum > income {
- fmt.Printf("We need %.2f leva more.\n", neededSum - income)
- } else {
- fmt.Println("Target acquired.")
- }
- fmt.Printf("Club income - %.2f leva.\n", income)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement