Advertisement
Spocoman

Suitcases Load

Oct 13th, 2024
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.84 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.   "fmt"
  5.   "strconv"
  6. )
  7.  
  8. func main() {
  9.     var availableArea, currentSuitcaseArea float64
  10.     fmt.Scanln(&availableArea)
  11.    
  12.     loadedSuitcases := 0
  13.    
  14.     var input string
  15.     fmt.Scanln(&input)
  16.    
  17.     for input != "End" {
  18.         currentSuitcaseArea,_ = strconv.ParseFloat(input, 64)
  19.         loadedSuitcases++
  20.         if loadedSuitcases % 3 == 0 {
  21.             currentSuitcaseArea *= 1.1
  22.         }
  23.         if (currentSuitcaseArea > availableArea) {
  24.             fmt.Println("No more space!")
  25.             loadedSuitcases--
  26.             break
  27.         }
  28.         availableArea -= currentSuitcaseArea
  29.         fmt.Scanln(&input)
  30.     }
  31.  
  32.     if input == "End" {
  33.         fmt.Println("Congratulations! All suitcases are loaded!")
  34.     }
  35.     fmt.Printf("Statistic: %d suitcases loaded.", loadedSuitcases)
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement