Advertisement
Spocoman

11. Trade Commissions

Sep 18th, 2024
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.39 KB | None | 0 0
  1. package main
  2. import "fmt"
  3.  
  4. func main() {
  5.     var town string
  6.     fmt.Scanln(&town)
  7.    
  8.     var profit float64
  9.     fmt.Scanln(&profit)
  10.    
  11.     var commission = 0.0
  12.  
  13.     if (town == "Sofia") {
  14.         if (profit > 0 && profit <= 500) {
  15.             commission = 0.05
  16.         } else if (profit > 500 && profit <= 1000) {
  17.             commission = 0.07
  18.         } else if (profit > 1000 && profit <= 10000) {
  19.             commission = 0.08
  20.         } else if (profit > 10000) {
  21.             commission = 0.12
  22.         }
  23.     } else if (town == "Varna") {
  24.         if (profit > 0 && profit <= 500) {
  25.             commission = 0.045
  26.         } else if (profit > 500 && profit <= 1000) {
  27.             commission = 0.075
  28.         } else if (profit > 1000 && profit <= 10000) {
  29.             commission = 0.1
  30.         } else if (profit > 10000) {
  31.             commission = 0.13
  32.         }
  33.     } else if (town == "Plovdiv") {
  34.         if (profit > 0 && profit <= 500) {
  35.             commission = 0.055
  36.         } else if (profit > 500 && profit <= 1000) {
  37.             commission = 0.08
  38.         } else if (profit > 1000 && profit <= 10000) {
  39.             commission = 0.12
  40.         } else if (profit > 10000) {
  41.                 commission = 0.145
  42.         }
  43.     }
  44.  
  45.     var sum = profit * commission
  46.  
  47.     if (sum > 0) {
  48.         fmt.Printf("%.2f\n", sum)
  49.     } else {
  50.         fmt.Println("error")
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement