Advertisement
Spocoman

Family Trip

Oct 9th, 2024
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.61 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.   "fmt"
  5.   "math"
  6. )
  7.  
  8. func main() {
  9.     var overnights, additionalCosts int
  10.     var budget, overnightPrice float64
  11.     fmt.Scanln(&budget)
  12.     fmt.Scanln(&overnights)
  13.     fmt.Scanln(&overnightPrice)
  14.     fmt.Scanln(&additionalCosts)
  15.    
  16.     if overnights > 7 {
  17.         overnightPrice *= 0.95
  18.     }
  19.  
  20.     budget -= overnightPrice * float64(overnights) + 0.01 * budget * float64(additionalCosts)
  21.  
  22.     if budget >= 0 {
  23.         fmt.Printf("Ivanovi will be left with %.2f leva after vacation.\n", budget)
  24.     } else {
  25.         fmt.Printf("%.2f leva needed.\n", math.Abs(budget))
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement