Advertisement
Spocoman

06. Flower Shop

Sep 16th, 2024
109
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. import (
  3.     "fmt"
  4.     "math"
  5. )
  6.  
  7. func main() {
  8.     const(
  9.         magnoliaPrice = 3.25
  10.         hyacinthPrice = 4.00
  11.         rosePrice = 3.50
  12.         cactusPrice = 8.00
  13.         taxProfit = 0.05
  14.     )
  15.    
  16.     var magnoliaCount, hyacinthCount, roseCount, cactusCount int
  17.     fmt.Scanln(&magnoliaCount)
  18.     fmt.Scanln(&hyacinthCount)
  19.     fmt.Scanln(&roseCount)
  20.     fmt.Scanln(&cactusCount)
  21.    
  22.     var gift float64
  23.     fmt.Scanln(&gift)
  24.  
  25.     var total = (magnoliaPrice * float64(magnoliaCount) + hyacinthPrice * float64(hyacinthCount)
  26.                     + rosePrice * float64(roseCount) + cactusPrice * float64(cactusCount)) * (1 - taxProfit);
  27.  
  28.     if (total >= gift){
  29.         fmt.Printf("She is left with %d leva.", (int)(total - gift));
  30.     } else {
  31.         fmt.Printf("She will have to borrow %d leva.", (int)(math.Ceil(gift - total)));
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement