Advertisement
Spocoman

06. Bills

Sep 21st, 2024
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.75 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var months int
  7.     fmt.Scanln(&months)
  8.    
  9.     var electricity = 0.0
  10.     var water = 20.00
  11.     var internet = 15.00
  12.     var other = 0.0
  13.    
  14.     var currentBill float64
  15.    
  16.     for i := 0; i < months; i++ {
  17.         fmt.Scanln(&currentBill)
  18.         electricity += currentBill
  19.         other += (currentBill + water + internet) * 1.2
  20.     }
  21.    
  22.     var average = (electricity + other) / float64(months) + water + internet
  23.  
  24.     fmt.Printf("Electricity: %.2f lv\n", electricity)
  25.     fmt.Printf("Water: %.2f lv\n", water * float64(months))
  26.     fmt.Printf("Internet: %.2f lv\n", internet * float64(months))
  27.     fmt.Printf("Other: %.2f lv\n", other)
  28.     fmt.Printf("Average: %.2f lv\n", average)
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement