Advertisement
Spocoman

Account Balance

Sep 26th, 2024
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.44 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "strconv"
  6. )
  7.  
  8. func main() {
  9.     var input string
  10.    
  11.     sum := 0.0
  12.  
  13.     for ; ; {
  14.         fmt.Scanln(&input)
  15.         if input == "NoMoreMoney"{
  16.              break
  17.         }
  18.         money, _ := strconv.ParseFloat(input, 64)
  19.         if money < 0 {
  20.             fmt.Println("Invalid operation!")
  21.             break
  22.         }
  23.         sum += money
  24.         fmt.Printf("Increase: %.2f\n", money)
  25.      }
  26.  
  27.     fmt.Printf("Total: %.2f\n", sum)
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement